public class ArrayUtil extends Object
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static int[] |
applyOrder(int[] arr,
int[] order)
Creates a copy of the given array such that it is ordered by the given order.
|
static int[] |
calcSortOrder(int[] arr1,
int[] arr2,
int length)
This method calculates the sort order of the first element-pairs given by two arrays.
|
static int[] |
calcSortOrder(com.carrotsearch.hppc.IntArrayList arr1,
com.carrotsearch.hppc.IntArrayList arr2) |
static com.carrotsearch.hppc.IntArrayList |
constant(int size,
int value)
Creates an IntArrayList of a given size where each element is set to the given value
|
static int[] |
invert(int[] arr)
Creates a new array where each element represents the index position of this element in the given array
or is set to -1 if this element does not appear in the input array.
|
static com.carrotsearch.hppc.IntArrayList |
invert(com.carrotsearch.hppc.IntArrayList list) |
static com.carrotsearch.hppc.IntArrayList |
iota(int size)
Creates an IntArrayList filled with the integers 0,1,2,3,...,size-1
|
static boolean |
isPermutation(com.carrotsearch.hppc.IntArrayList arr) |
static int[] |
merge(int[] a,
int[] b) |
static com.carrotsearch.hppc.IntArrayList |
permutation(int size,
Random rnd)
Creates an IntArrayList filled with a permutation of the numbers 0,1,2,...,size-1
|
static com.carrotsearch.hppc.IntArrayList |
range(int startIncl,
int endExcl)
Creates an IntArrayList filled with the integers [startIncl,endExcl[
|
static com.carrotsearch.hppc.IntArrayList |
rangeClosed(int startIncl,
int endIncl)
Creates an IntArrayList filled with the integers [startIncl,endIncl]
|
static int |
removeConsecutiveDuplicates(int[] arr,
int end)
Removes all duplicate elements of the given array in the range [0, end[ in place
|
static com.carrotsearch.hppc.IntArrayList |
reverse(com.carrotsearch.hppc.IntArrayList list)
Reverses the order of the given list's elements in place and returns it
|
static com.carrotsearch.hppc.IntArrayList |
shuffle(com.carrotsearch.hppc.IntArrayList list,
Random random)
Shuffles the elements of the given list in place and returns it
|
static void |
transform(com.carrotsearch.hppc.IntIndexedContainer arr,
com.carrotsearch.hppc.IntIndexedContainer map)
Maps one array using another, i.e.
|
static com.carrotsearch.hppc.IntIndexedContainer |
withoutConsecutiveDuplicates(com.carrotsearch.hppc.IntIndexedContainer arr)
Creates a copy of the given list where all consecutive duplicates are removed
|
static com.carrotsearch.hppc.IntArrayList |
zero(int size)
Creates an IntArrayList filled with zeros
|
public static com.carrotsearch.hppc.IntArrayList constant(int size, int value)
public static com.carrotsearch.hppc.IntArrayList zero(int size)
public static com.carrotsearch.hppc.IntArrayList iota(int size)
public static com.carrotsearch.hppc.IntArrayList range(int startIncl, int endExcl)
public static com.carrotsearch.hppc.IntArrayList rangeClosed(int startIncl, int endIncl)
public static com.carrotsearch.hppc.IntArrayList permutation(int size, Random rnd)
public static boolean isPermutation(com.carrotsearch.hppc.IntArrayList arr)
public static com.carrotsearch.hppc.IntArrayList reverse(com.carrotsearch.hppc.IntArrayList list)
public static com.carrotsearch.hppc.IntArrayList shuffle(com.carrotsearch.hppc.IntArrayList list, Random random)
public static int removeConsecutiveDuplicates(int[] arr, int end)
public static com.carrotsearch.hppc.IntIndexedContainer withoutConsecutiveDuplicates(com.carrotsearch.hppc.IntIndexedContainer arr)
public static void transform(com.carrotsearch.hppc.IntIndexedContainer arr, com.carrotsearch.hppc.IntIndexedContainer map)
public static int[] calcSortOrder(com.carrotsearch.hppc.IntArrayList arr1, com.carrotsearch.hppc.IntArrayList arr2)
public static int[] calcSortOrder(int[] arr1, int[] arr2, int length)
length
- must not be larger than either of the two input array lengths.public static int[] applyOrder(int[] arr, int[] order)
public static int[] invert(int[] arr)
public static com.carrotsearch.hppc.IntArrayList invert(com.carrotsearch.hppc.IntArrayList list)
public static int[] merge(int[] a, int[] b)
a
- sorted arrayb
- sorted arrayCopyright © 2012–2021. All rights reserved.