Package frc.lib.util
Class IntArrayList
java.lang.Object
frc.lib.util.IntArrayList
- All Implemented Interfaces:
Serializable
,Cloneable
,RandomAccess
An optimized int array. Used in lieu of an
ArrayList<Integer>
to avoid boxing (and the
performance implications that come with it).- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]
static final int
During list creation, many reallocations at low capacities may be common, so we jump from 0 to 10 before our normal reallocation scheme.protected int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int k) Appendsk
to the end of this list.void
clear()
Remove all values.int
get
(int index) Get long element at indexindex
.boolean
isEmpty()
Checks if the list has no elements.int
remove
(int index) Removes the element at the specified position in this list.int
size()
Returns the number of elements in this list.int[]
toArray()
Convert to an array.
-
Field Details
-
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITYDuring list creation, many reallocations at low capacities may be common, so we jump from 0 to 10 before our normal reallocation scheme.- See Also:
-
backing
protected transient int[] backing -
size
protected int size
-
-
Constructor Details
-
IntArrayList
public IntArrayList()Creates a new array list withDEFAULT_INITIAL_CAPACITY
capacity.
-
-
Method Details
-
add
public void add(int k) Appendsk
to the end of this list. -
get
public int get(int index) Get long element at indexindex
. -
isEmpty
public boolean isEmpty()Checks if the list has no elements. -
size
public int size()Returns the number of elements in this list. -
remove
public int remove(int index) Removes the element at the specified position in this list. -
clear
public void clear()Remove all values. -
toArray
public int[] toArray()Convert to an array. This performs a copy, since the backing array may be larger than the array needed to be returned.
-