Package uk.ac.starlink.util
Class LongList
java.lang.Object
uk.ac.starlink.util.PrimitiveList
uk.ac.starlink.util.LongList
Extendable array of longs..
- Since:
- 12 Oct 2006
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long value) Appends a value to the end of this list.boolean
addAll
(long[] array) Appends all the elements of a primitive array to this list.boolean
Appends all the elements of a second list to this list.long
get
(int i) Returns the element at a given position.long[]
Returns the array currently used to store the contents of this list.void
set
(int i, long value) Sets the element at a given position.long[]
Returns the contents of this list as an array.Methods inherited from class uk.ac.starlink.util.PrimitiveList
clear, nextCapacity, size, toArray
-
Constructor Details
-
LongList
public LongList()Constructs a new list. -
LongList
public LongList(int size) Constructs a new list with a given initial capacity.- Parameters:
size
- initial capacity
-
LongList
public LongList(long[] array) Constructs a new list initialised to the contents of a given array.- Parameters:
array
- array whose contents form initial contents of list
-
-
Method Details
-
get
public long get(int i) Returns the element at a given position.- Parameters:
i
- index- Returns:
- element at
i
-
set
public void set(int i, long value) Sets the element at a given position.- Parameters:
i
- indexvalue
- new value for elementi
-
add
public void add(long value) Appends a value to the end of this list.- Parameters:
value
- value to append
-
addAll
Appends all the elements of a second list to this list.- Parameters:
other
- other list- Returns:
- true iff this collection changed as a result of the call
-
addAll
public boolean addAll(long[] array) Appends all the elements of a primitive array to this list.- Parameters:
array
- array to append- Returns:
- true iff this collection changed as a result of the call
-
toLongArray
public long[] toLongArray()Returns the contents of this list as an array.- Returns:
- copy of list contents
-
getLongBuffer
public long[] getLongBuffer()Returns the array currently used to store the contents of this list. Its length will be greater than or equal to the length of this list. The identity of the returned array may change as this list is mutated.- Returns:
- storage array
-