Modifier and Type | Field and Description |
---|---|
int[] |
data
This is the array of integers being used and should never be set to null.
|
int |
growSize
This specifies the number of values to increase by when expansion is
needed.
|
int |
length
This specifies the number of valid values in the array.
|
Constructor and Description |
---|
IntArray()
Creates an IntArray with an initial length of zero, a capacity of 100 and a grow size of -1.
|
IntArray(int initialSize,
int growSize)
Creates an IntArray of zero length with the specified initial capacity and grow size.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int value)
Append a value to the end of the array.
|
void |
append(int value) |
void |
append(int[] values,
int offset,
int length) |
int[] |
appendTo(int[] dest)
Append all values in this IntArray to the specified destination array.
|
int[] |
appendTo(int[] dest,
boolean reverse)
Append all values in this IntArray to the specified destination array with
the option of reversing the order of integers in this IntArray before appending.
|
void |
clear()
Clears the IntArray completely.
|
void |
copyInto(int[] dest,
int offset)
Copy all values into the destination array at the specified offset.
|
void |
ensureCapacity(int newCapacity)
This makes sure the data array has at least totalBytes in it.
|
Object |
getCopy()
Return a copy of this object.
|
static int[] |
getEmpty()
Get a re-usable empty int array.
|
int |
indexOf(int value)
Find the index of the specified value.
|
void |
insert(int[] values,
int offset,
int length,
int where) |
void |
insert(int value,
int index)
Insert a value at the specified index.
|
boolean |
makeSpace(int where,
int num)
This adds space to the IntArray at the specified index, increasing the
length value by num.
|
int |
prepareReceive(int toReceive,
boolean append)
Make enough space to receive incoming data up to a maximum of toReceive bytes.
|
void |
received(int received)
Call this after calling prepareReceive() and after having received some or zero data.
|
void |
remove(int value)
Remove the value if it is in the array.
|
void |
removeAtIndex(int index)
Remove the value at the specified index.
|
void |
setLength(int len)
This sets the length of the valid data within the array and will either truncate or extend
the array as necessary.
|
int[] |
takeData()
Take the data from the IntArray leaving it with length 0 and with a new
empty data.
|
int[] |
toIntArray()
Return a copy of the array of integers whose length exactly holds
all added integers.
|
protected void |
toNewLength(int newLength)
Moves the data into a new data array of the specified length - which
must be greater than or equal to the number of elements in the array.
|
String |
toString()
Return a String representation of this object.
|
static String |
toString(int[] data,
int start,
int len)
Put an array of integers as a printable string of values separated
by commas and enclosed in [].
|
static void |
toString(int[] data,
int start,
int len,
StringBuffer dest)
Put an array of integers as a printable string of values separated
by commas.
|
public int[] data
public int length
public int growSize
public IntArray()
public IntArray(int initialSize, int growSize)
the
- initial size of the IntArray.growSize
- the minimum amount to increase the array by when expanding. If it is negative
then the size doubles whenever it needs to increase.public int[] takeData()
public static final int[] getEmpty()
public Object getCopy()
Copyable
public void clear()
public void add(int value)
public void append(int value)
public boolean makeSpace(int where, int num)
public void insert(int[] values, int offset, int length, int where)
public void append(int[] values, int offset, int length)
public void insert(int value, int index)
public int indexOf(int value)
public void remove(int value)
public void removeAtIndex(int index)
public int[] toIntArray()
public void copyInto(int[] dest, int offset)
public int[] appendTo(int[] dest)
public int[] appendTo(int[] dest, boolean reverse)
public int prepareReceive(int toReceive, boolean append)
toReceive
- the maximum number of bytes to receive.append
- if this is false the length is set to zero.public void received(int received)
received
- the number of bytes actually received.public void setLength(int len)
protected void toNewLength(int newLength)
public void ensureCapacity(int newCapacity)
public static void toString(int[] data, int start, int len, StringBuffer dest)
data
- start
- len
- dest
- public static String toString(int[] data, int start, int len)
data
- start
- len
-