public final class GrowingArrayUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean[] |
append(boolean[] array,
int currentSize,
boolean element)
Primitive boolean version of
append(Object[], int, Object) . |
static float[] |
append(float[] array,
int currentSize,
float element)
Primitive float version of
append(Object[], int, Object) . |
static int[] |
append(int[] array,
int currentSize,
int element)
Primitive int version of
append(Object[], int, Object) . |
static long[] |
append(long[] array,
int currentSize,
long element)
Primitive long version of
append(Object[], int, Object) . |
static <T> T[] |
append(T[] array,
int currentSize,
T element)
Appends an element to the end of the array, growing the array if there is no more room.
|
static int |
growSize(int currentSize)
Given the current size of an array, returns an ideal size to which the array should grow.
|
static boolean[] |
insert(boolean[] array,
int currentSize,
int index,
boolean element)
Primitive boolean version of
insert(Object[], int, int, Object) . |
static int[] |
insert(int[] array,
int currentSize,
int index,
int element)
Primitive int version of
insert(Object[], int, int, Object) . |
static long[] |
insert(long[] array,
int currentSize,
int index,
long element)
Primitive long version of
insert(Object[], int, int, Object) . |
static <T> T[] |
insert(T[] array,
int currentSize,
int index,
T element)
Inserts an element into the array at the specified index, growing the array if there is no
more room.
|
public static <T> T[] append(T[] array, int currentSize, T element)
array
- The array to which to append the element. This must NOT be null.currentSize
- The number of elements in the array. Must be less than or equal to
array.length.element
- The element to append.public static int[] append(int[] array, int currentSize, int element)
append(Object[], int, Object)
.public static long[] append(long[] array, int currentSize, long element)
append(Object[], int, Object)
.public static boolean[] append(boolean[] array, int currentSize, boolean element)
append(Object[], int, Object)
.public static float[] append(float[] array, int currentSize, float element)
append(Object[], int, Object)
.public static <T> T[] insert(T[] array, int currentSize, int index, T element)
array
- The array to which to append the element. Must NOT be null.currentSize
- The number of elements in the array. Must be less than or equal to
array.length.element
- The element to insert.public static int[] insert(int[] array, int currentSize, int index, int element)
insert(Object[], int, int, Object)
.public static long[] insert(long[] array, int currentSize, int index, long element)
insert(Object[], int, int, Object)
.public static boolean[] insert(boolean[] array, int currentSize, int index, boolean element)
insert(Object[], int, int, Object)
.public static int growSize(int currentSize)