public class IntArray
extends java.lang.Object
Constructor and Description |
---|
IntArray()
Create an empty int array.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int i)
Adds an integer to the array.
|
void |
add(IntArray array)
Appends the integers in array to the end of this array.
|
void |
add(int i,
int value)
Inserts an integer into the array.
|
void |
clear()
clear the array, i.e.
|
boolean |
contains(int test)
Returns true if the array contains and integer equal to test.
|
int |
get(int i)
Gets the integer value at the given index.
|
int[] |
getArray()
Returns the data array.
|
boolean |
isSubset(IntArray subset)
True if all the integers in subset are contained in the array.
|
int |
last()
Returns the last integer in the array.
|
int |
pop()
Pops the value off the end of the array.
|
void |
set(int i,
int value)
Sets the value at the given index.
|
void |
setLength(int size)
Sets the length of the array, filling with zero if necessary.
|
int |
size()
Returns the current size of the array
|
int[] |
toArray()
Return a new int array with the contents.
|
java.lang.String |
toString() |
void |
union(IntArray newArray)
Adds the members of newArray to the list if they are not already
members of the array.
|
public void clear()
public int size()
public int[] getArray()
public void add(int i)
public void add(IntArray array)
public void add(int i, int value)
public int pop()
public void setLength(int size)
public int get(int i)
i
- index into the array.public int last()
public void set(int i, int value)
public boolean contains(int test)
public boolean isSubset(IntArray subset)
public void union(IntArray newArray)
public int[] toArray()
public java.lang.String toString()
toString
in class java.lang.Object