Class LongArrayList
java.lang.Object
smile.util.LongArrayList
- All Implemented Interfaces:
Serializable
A resizeable, array-backed list of
long primitives.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty list with initial capacity 10.LongArrayList(int capacity) Constructs an empty list with the specified initial capacity.LongArrayList(long[] values) Constructs a list containing the values of the specified array. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long val) Appends the specified value to the end of this list.voidadd(long[] vals) Appends all values in the specified array.voidclear()Removes all elements from the list.voidensureCapacity(int capacity) Ensures capacity is at leastcapacity.longget(int index) Returns the element at the specified index.booleanisEmpty()Returnstrueif this list contains no elements.voidset(int index, long val) Sets the element at the specified index.intsize()Returns the number of elements.stream()Returns the stream of elements.long[]toArray()Returns an array containing all elements in proper sequence.toString()
-
Constructor Details
-
LongArrayList
public LongArrayList()Constructs an empty list with initial capacity 10. -
LongArrayList
public LongArrayList(int capacity) Constructs an empty list with the specified initial capacity.- Parameters:
capacity- the initial capacity.
-
LongArrayList
public LongArrayList(long[] values) Constructs a list containing the values of the specified array.- Parameters:
values- the initial values.
-
-
Method Details
-
toString
-
stream
-
ensureCapacity
public void ensureCapacity(int capacity) Ensures capacity is at leastcapacity.- Parameters:
capacity- the minimum required capacity.
-
size
public int size()Returns the number of elements.- Returns:
- the number of elements.
-
isEmpty
public boolean isEmpty()Returnstrueif this list contains no elements.- Returns:
trueif empty.
-
get
public long get(int index) Returns the element at the specified index.- Parameters:
index- the index.- Returns:
- the element.
-
set
public void set(int index, long val) Sets the element at the specified index.- Parameters:
index- the index.val- the new value.
-
add
public void add(long val) Appends the specified value to the end of this list.- Parameters:
val- the value.
-
add
public void add(long[] vals) Appends all values in the specified array.- Parameters:
vals- the values.
-
clear
public void clear()Removes all elements from the list. -
toArray
public long[] toArray()Returns an array containing all elements in proper sequence.- Returns:
- a copy of the backing array trimmed to size.
-