public final class ArrayIntList extends Object
int
elements;
implemented with arrays.Constructor and Description |
---|
ArrayIntList()
Constructs an empty list.
|
ArrayIntList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int elem)
Appends the specified element to the end of this list.
|
void |
add(int[] elems,
int offset,
int length)
Appends the elements in the range
[offset..offset+length) to the end of this list. |
int[] |
asArray()
Returns the elements currently stored, including invalid elements between
size and capacity, if any.
|
void |
clear()
Removes all elements but keeps the current capacity; Afterwards
size() will yield zero. |
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of
elements without needing to allocate new internal memory.
|
int |
size()
Returns the number of contained elements.
|
int[] |
toArray()
Returns a copied array of bytes containing all elements; the returned
array has length = this.size().
|
public ArrayIntList()
public ArrayIntList(int initialCapacity)
initialCapacity
- the number of elements the receiver can hold without
auto-expanding itself by allocating new internal memory.public void add(int elem)
elem
- element to be appended to this list.public void add(int[] elems, int offset, int length)
[offset..offset+length)
to the end of this list.elems
- the elements to be appendedoffset
- the offset of the first element to add (inclusive)length
- the number of elements to addIndexOutOfBoundsException
- if indexes are out of range.public int[] asArray()
WARNING: For efficiency reasons and to keep memory usage low, the array is SHARED, not copied . So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing.
public void clear()
size()
will yield zero.public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.public int size()
public int[] toArray()
Copyright © 2018 JBoss by Red Hat. All rights reserved.