Package com.amazon.ion.impl.bin
Class IntList
- java.lang.Object
-
- com.amazon.ion.impl.bin.IntList
-
public class IntList extends java.lang.ObjectA list of integer values that grows as necessary. UnlikeList, IntList does not require each int to be boxed. This makes it helpful in use cases where storingIntegerleads to excessive time spent in garbage collection.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_INITIAL_CAPACITY
-
Constructor Summary
Constructors Constructor Description IntList()Constructs a new IntList with a capacity ofDEFAULT_INITIAL_CAPACITY.IntList(int initialCapacity)Constructs a new IntList with the specified capacity.IntList(IntList other)Constructs a new IntList that contains all the elements of the given IntList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int value)Appends an int to the end of the list, growing the list if necessary.voidclear()Empties the list.intget(int index)Returns theindexth int in the list.booleanisEmpty()intsize()Accessor.java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IntList
public IntList()
Constructs a new IntList with a capacity ofDEFAULT_INITIAL_CAPACITY.
-
IntList
public IntList(int initialCapacity)
Constructs a new IntList with the specified capacity.- Parameters:
initialCapacity- The number of ints that can be stored in this IntList before it will need to be reallocated.
-
IntList
public IntList(IntList other)
Constructs a new IntList that contains all the elements of the given IntList.- Parameters:
other- the IntList to copy.
-
-
Method Detail
-
size
public int size()
Accessor.- Returns:
- The number of ints currently stored in the list.
-
isEmpty
public boolean isEmpty()
- Returns:
trueif there are ints stored in the list.
-
clear
public void clear()
Empties the list. Note that this method does not shrink the size of the backing data store.
-
get
public int get(int index)
Returns theindexth int in the list.- Parameters:
index- The list index of the desired int.- Returns:
- The int at index
indexin the list. - Throws:
java.lang.IndexOutOfBoundsException- if the index is negative or greater than the number of ints stored in the list.
-
add
public void add(int value)
Appends an int to the end of the list, growing the list if necessary.- Parameters:
value- The int to add to the end of the list.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-