Package com.pnfsoftware.jeb.util.collect
Class IntList
java.lang.Object
com.pnfsoftware.jeb.util.collect.IntList
A memory-efficient list of
int primitives. Additions, retrieval, updates are supported.
Deletes and insertions are not supported.
This class is not thread-safe.
Note: Object.hashCode() and Object.equals(Object) are not overridden.
Implementation note: internally, the primitives are stored in multiple buckets. The user may specify an initial bucket capacity and maximum capacity.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
IntList
public IntList()Create a list with an initial capacity of 16 and bucket capacity of 65,536. -
IntList
public IntList(int initialCapacity, int bucketCapacity) Create a list with custom bucket sizing.- Parameters:
initialCapacity- initial bucket capacitybucketCapacity- maximum bucket capacity
-
-
Method Details
-
size
public int size()- Returns:
- number of elements
-
isEmpty
public boolean isEmpty()- Returns:
- true if this list has no elements
-
clear
public void clear()Remove all elements. -
get
public int get(int index) Retrieve an element.- Parameters:
index- element index- Returns:
- value at the index
-
add
public void add(int val) Append a value.- Parameters:
val- value to append
-
set
public void set(int index, int val) Update an element.- Parameters:
index- element indexval- new value
-
toString
-