Package com.knuddels.jtokkit.api
Class IntArrayList
java.lang.Object
com.knuddels.jtokkit.api.IntArrayList
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty list with an initial capacity of ten.IntArrayList(int initialCapacity) Constructs an empty list with the specified initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int element) Appends the specified element to the end of this list.boxed()Returns aList<Integer>containing all the elements in this list in proper sequence (from first to last element).voidclear()Removes all the elements from this list.voidensureCapacity(int minCapacity) Increases the capacity of thisIntArrayListinstance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.booleanintget(int index) Returns the element at the specified position in this list.inthashCode()booleanisEmpty()Returnstrueif this list contains no elements.intset(int index, int element) Replaces the element at the specified position in this list with the specified element.intsize()Returns the number of elements in this list.int[]toArray()Returns an array containing all the elements in this list in proper sequence (from first to last element).toString()
-
Constructor Details
-
IntArrayList
public IntArrayList()Constructs an empty list with an initial capacity of ten. -
IntArrayList
public IntArrayList(int initialCapacity) Constructs an empty list with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity of the list- Throws:
IllegalArgumentException- if the specified initial capacity is negative
-
-
Method Details
-
clear
public void clear()Removes all the elements from this list. The list will be empty after this call returns. -
add
public void add(int element) Appends the specified element to the end of this list.- Parameters:
element- element to be appended to this list
-
get
public int get(int index) Returns the element at the specified position in this list.- Parameters:
index- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
-
set
public int set(int index, int element) Replaces the element at the specified position in this list with the specified element.- Parameters:
index- index of the element to replaceelement- element to be stored at the specified position- Returns:
- the element previously at the specified position
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
-
ensureCapacity
public void ensureCapacity(int minCapacity) Increases the capacity of thisIntArrayListinstance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity
-
size
public int size()Returns the number of elements in this list.- Returns:
- the number of elements in this list
-
isEmpty
public boolean isEmpty()Returnstrueif this list contains no elements.- Returns:
trueif this list contains no elements
-
toArray
public int[] toArray()Returns an array containing all the elements in this list in proper sequence (from first to last element).The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
- Returns:
- an array containing all the elements in this list in proper sequence
-
boxed
Returns aList<Integer>containing all the elements in this list in proper sequence (from first to last element).The returned list will be "safe" in that no reference to it are maintained by this list. (In other words, this method must allocate a new list). The caller is thus free to modify the returned list.
- Returns:
- a
List<Integer>containing all the elements in this list in proper sequence
-
equals
-
hashCode
public int hashCode() -
toString
-