public final class ArrayUtil
extends java.lang.Object
In all cases the array being mutated is assumed to be full.
In all cases reference equality is used.
Modifier and Type | Field and Description |
---|---|
static boolean[] |
EMPTY_BOOLEAN_ARRAY |
static byte[] |
EMPTY_BYTE_ARRAY |
static char[] |
EMPTY_CHAR_ARRAY |
static double[] |
EMPTY_DOUBLE_ARRAY |
static float[] |
EMPTY_FLOAT_ARRAY |
static int[] |
EMPTY_INT_ARRAY |
static long[] |
EMPTY_LONG_ARRAY |
static java.lang.Object[] |
EMPTY_OBJECT_ARRAY |
static short[] |
EMPTY_SHORT_ARRAY |
static java.lang.String[] |
EMPTY_STRING_ARRAY |
static int |
UNKNOWN_INDEX |
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
add(T[] oldElements,
T elementToAdd)
Add an element to an array resulting in a new array.
|
static <T> T[] |
ensureCapacity(T[] oldElements,
int requiredLength)
Ensure an array has the required capacity.
|
static <T> T[] |
newArray(T[] oldElements,
int length)
Allocate a new array of the same type as another array.
|
static <T> T[] |
remove(T[] oldElements,
int index) |
static <T> T[] |
remove(T[] oldElements,
T elementToRemove)
Remove an element from an array resulting in a new array if the element was found otherwise the old array.
|
public static final int UNKNOWN_INDEX
public static final boolean[] EMPTY_BOOLEAN_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY
public static final char[] EMPTY_CHAR_ARRAY
public static final short[] EMPTY_SHORT_ARRAY
public static final int[] EMPTY_INT_ARRAY
public static final float[] EMPTY_FLOAT_ARRAY
public static final long[] EMPTY_LONG_ARRAY
public static final double[] EMPTY_DOUBLE_ARRAY
public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
public static final java.lang.String[] EMPTY_STRING_ARRAY
public static <T> T[] add(T[] oldElements, T elementToAdd)
T
- type of the array.oldElements
- to have the new element added.elementToAdd
- for the new array.public static <T> T[] remove(T[] oldElements, T elementToRemove)
Returns its input parameter if the element to remove isn't a member.
T
- type of the array.oldElements
- to have the element removed from.elementToRemove
- being searched for by identity semantics.public static <T> T[] remove(T[] oldElements, int index)
public static <T> T[] newArray(T[] oldElements, int length)
T
- type of the array.oldElements
- on which the new array is based.length
- of the new array.public static <T> T[] ensureCapacity(T[] oldElements, int requiredLength)
T
- type of the array.oldElements
- to ensure that are long enough.requiredLength
- to ensure.Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.