public class ArrayHelper
extends java.lang.Object
| Constructor and Description |
|---|
ArrayHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
append(T[] original,
T toAppend,
boolean allowDuplicates) |
static <E> boolean |
contains(E[] array,
E value) |
static int |
countOccurrences(java.lang.Object array,
java.lang.Object occurance) |
static <T> T[] |
create(java.lang.Class<T> clazz,
int length)
Creates an array with the input dimensions.
|
static <T> T[] |
createMulti(java.lang.Class<T> clazz,
int[] lengths)
Creates a potentially multidimensional array with the input dimensions.
|
static <T> T[] |
deduplicate(T[] array,
boolean replaceValues,
T replacement,
T... valuesToIgnore)
Removes all duplicate values from the input array.
|
static <T> T[] |
deduplicate(T[] array,
T... valuesToIgnore)
Removes all duplicate values from the input array.
|
static <T> T[] |
expand(T[] original,
java.lang.Class<T> clazz)
Increases the size of the array by 1.
|
static <E> int |
findFirstOccurrence(E[] array,
E element)
Returns -1 if the element is not found in the array
|
static <E> int |
findFirstOccurrenceAfter(E[] array,
E element,
int index)
Returns -1 if the element is not found in the array after the index
|
static boolean[] |
fixBoxedPrimitive(java.lang.Boolean... boxed)
Probably should be avoided but serves as an easy way to unbox Boolean arrays
|
static byte[] |
fixBoxedPrimitive(java.lang.Byte... boxed)
Probably should be avoided but serves as an easy way to unbox Boolean arrays
|
static char[] |
fixBoxedPrimitive(java.lang.Character... boxed)
Probably should be avoided but serves as an easy way to unbox Character arrays
|
static double[] |
fixBoxedPrimitive(java.lang.Double... boxed)
Probably should be avoided but serves as an easy way to unbox Double arrays
|
static float[] |
fixBoxedPrimitive(java.lang.Float... boxed)
Probably should be avoided but serves as an easy way to unbox Float arrays
|
static int[] |
fixBoxedPrimitive(java.lang.Integer... boxed)
Probably should be avoided but serves as an easy way to unbox Integer arrays
|
static long[] |
fixBoxedPrimitive(java.lang.Long... boxed)
Probably should be avoided but serves as an easy way to unbox Long arrays
|
static short[] |
fixBoxedPrimitive(java.lang.Short... boxed)
Probably should be avoided but serves as an easy way to unbox Short arrays
|
static <E> E[] |
fixObjParsed(java.lang.Object[] array,
java.lang.Class<?> fixAs) |
static <E> E[] |
forEach(E[] array,
java.util.function.BiConsumer<E,java.lang.Integer> consumer) |
static <T> T[] |
fromIterable(java.lang.Iterable<?> itr,
java.lang.Class<T> clazz) |
static <T> T[] |
fromIterator(java.util.Iterator<?> itr,
java.lang.Class<T> clazz) |
static <E> boolean |
hasElement(E[] array,
E element) |
static <E> boolean |
hasElementAfter(E[] array,
E element,
int index) |
static <E> boolean |
hasElementExceptAt(E[] array,
E element,
int index) |
static int[] |
intRange(int min,
int max) |
static int[] |
intRange(int min,
int max,
boolean inclusive) |
static <E> boolean |
isEmpty(E[] array) |
static <E> boolean |
isNotEmpty(E[] array) |
static <E,T> T[] |
mapTo(E[] array,
java.lang.Class<T> clazz,
java.util.function.Function<E,T> remapper) |
static boolean |
matches(@Nullable java.lang.Object[] array,
@Nullable java.lang.Object other)
Runs non-strict equality rules.
|
static boolean |
matchesArray(@Nullable java.lang.Object[] array,
@Nullable java.lang.Object[] other) |
static <E> E[] |
removeAllOccurrencesAfter(E[] array,
E element,
int after) |
static <E> E[] |
removeAllOccurrencesOf(E[] array,
E element) |
static <E> E[] |
removeElement(E[] array,
int index) |
static <E> E[] |
removeMatching(E[] array,
E toMatch,
java.util.function.Function<E,java.lang.Boolean> matcher) |
static <E,F> void |
supplyArray(E[] array,
F thing,
java.util.function.BiFunction<F,java.lang.Integer,E> func) |
static <E> void |
supplyArray(E[] array,
java.util.function.Function<java.lang.Integer,E> func) |
static <E,F> java.lang.Object |
supplyArrayCreation(java.lang.Class<E> clazz,
int size,
F thing,
java.util.function.BiFunction<F,java.lang.Integer,?> func) |
static <E> java.lang.Object |
supplyArrayCreation(java.lang.Class<E> clazz,
int size,
java.util.function.Function<java.lang.Integer,?> func) |
public static <T> T[] append(T[] original,
T toAppend,
boolean allowDuplicates)
public static <E> boolean contains(E[] array,
E value)
public static int countOccurrences(java.lang.Object array,
java.lang.Object occurance)
public static <T> T[] create(java.lang.Class<T> clazz,
int length)
public static <T> T[] createMulti(java.lang.Class<T> clazz,
int[] lengths)
@SafeVarargs
public static <T> T[] deduplicate(T[] array,
T... valuesToIgnore)
@SafeVarargs
public static <T> T[] deduplicate(T[] array,
boolean replaceValues,
T replacement,
T... valuesToIgnore)
public static <T> T[] expand(T[] original,
java.lang.Class<T> clazz)
public static <E> int findFirstOccurrence(E[] array,
E element)
public static <E> int findFirstOccurrenceAfter(E[] array,
E element,
int index)
public static boolean[] fixBoxedPrimitive(java.lang.Boolean... boxed)
public static byte[] fixBoxedPrimitive(java.lang.Byte... boxed)
public static char[] fixBoxedPrimitive(java.lang.Character... boxed)
public static double[] fixBoxedPrimitive(java.lang.Double... boxed)
public static float[] fixBoxedPrimitive(java.lang.Float... boxed)
public static int[] fixBoxedPrimitive(java.lang.Integer... boxed)
public static long[] fixBoxedPrimitive(java.lang.Long... boxed)
public static short[] fixBoxedPrimitive(java.lang.Short... boxed)
public static <E> E[] fixObjParsed(java.lang.Object[] array,
java.lang.Class<?> fixAs)
public static <E> E[] forEach(E[] array,
java.util.function.BiConsumer<E,java.lang.Integer> consumer)
public static <T> T[] fromIterable(java.lang.Iterable<?> itr,
java.lang.Class<T> clazz)
public static <T> T[] fromIterator(java.util.Iterator<?> itr,
java.lang.Class<T> clazz)
public static <E> boolean hasElement(E[] array,
E element)
public static <E> boolean hasElementAfter(E[] array,
E element,
int index)
public static <E> boolean hasElementExceptAt(E[] array,
E element,
int index)
public static int[] intRange(int min,
int max)
public static int[] intRange(int min,
int max,
boolean inclusive)
public static <E> boolean isEmpty(E[] array)
public static <E> boolean isNotEmpty(E[] array)
public static <E,T> T[] mapTo(E[] array,
java.lang.Class<T> clazz,
java.util.function.Function<E,T> remapper)
public static boolean matches(@Nullable
@Nullable java.lang.Object[] array,
@Nullable
@Nullable java.lang.Object other)
public static boolean matchesArray(@Nullable
@Nullable java.lang.Object[] array,
@Nullable
@Nullable java.lang.Object[] other)
public static <E> E[] removeAllOccurrencesAfter(E[] array,
E element,
int after)
public static <E> E[] removeAllOccurrencesOf(E[] array,
E element)
public static <E> E[] removeElement(E[] array,
int index)
public static <E> E[] removeMatching(E[] array,
E toMatch,
java.util.function.Function<E,java.lang.Boolean> matcher)
public static <E> void supplyArray(E[] array,
java.util.function.Function<java.lang.Integer,E> func)
public static <E,F> void supplyArray(E[] array,
F thing,
java.util.function.BiFunction<F,java.lang.Integer,E> func)
public static <E> java.lang.Object supplyArrayCreation(java.lang.Class<E> clazz,
int size,
java.util.function.Function<java.lang.Integer,?> func)
public static <E,F> java.lang.Object supplyArrayCreation(java.lang.Class<E> clazz,
int size,
F thing,
java.util.function.BiFunction<F,java.lang.Integer,?> func)