public final class ArrayUtil
extends java.lang.Object
is a collection of static methods to manipulate arrays. The idea
is that the currently used area in the array is stored somewhere
else. The functions in here, except resize()
,
pretend the whole array is in use.
This will hopefully be mostly obsoleted as soon as we have generics. The set of methods is not in any way complete, because I only add what I just needed.
Modifier and Type | Method and Description |
---|---|
static void |
delete(byte[] ary,
int pos,
int count)
deletes
count elements from ary
starting at index pos by copying the elements
at indices greater than or equal to pos+count to
index pos . |
static void |
delete(int[] ary,
int pos,
int count)
deletes
count elements from ary
starting at index pos by copying the elements
at indices greater than or equal to pos+count to
index pos . |
static void |
delete(java.lang.Object[] ary,
int pos,
int count) |
static void |
insert(byte[] ary,
int pos,
byte elem) |
static void |
insert(char[] ary,
int pos,
char elem) |
static void |
insert(int[] ary,
int pos,
int elem)
inserts
elem at index pos in
ary by shifting all elements at indices greater
pos to a one larger index position. |
static void |
insert(java.lang.Object[] ary,
int pos,
java.lang.Object o) |
static byte[] |
resize(byte[] old,
int newSize) |
static char[] |
resize(char[] old,
int newSize) |
static int[] |
resize(int[] old,
int newSize)
allocates a new array with the given
newSize and
copies the content of old into the new array up to
the maximum of newSize or
old.length . |
static java.lang.Object[] |
resize(java.lang.Object[] old,
int newSize) |
public static int[] resize(int[] old, int newSize)
allocates a new array with the given newSize
and
copies the content of old
into the new array up to
the maximum of newSize
or
old.length
.
public static void insert(int[] ary, int pos, int elem)
elem
at index pos
in
ary
by shifting all elements at indices greater
pos
to a one larger index position. The very last
element of the array is lost.public static void delete(int[] ary, int pos, int count)
deletes count
elements from ary
starting at index pos
by copying the elements
at indices greater than or equal to pos+count
to
index pos
. The elements which become "free" at the
end of the array are not touched and the array is not
resized. Call resize()
afterwards to
reallocate the array.
public static void delete(byte[] ary, int pos, int count)
deletes count
elements from ary
starting at index pos
by copying the elements
at indices greater than or equal to pos+count
to
index pos
.
delete(int[],int,int)
public static char[] resize(char[] old, int newSize)
resize(int[],int)
public static void insert(char[] ary, int pos, char elem)
insert(int[],int,int)
public static byte[] resize(byte[] old, int newSize)
resize(int[],int)
public static void insert(byte[] ary, int pos, byte elem)
insert(int[],int,int)
public static java.lang.Object[] resize(java.lang.Object[] old, int newSize)
resize(int[],int)
public static void insert(java.lang.Object[] ary, int pos, java.lang.Object o)
insert(int[],int,int)
public static void delete(java.lang.Object[] ary, int pos, int count)
delete(int[],int,int)