Package uk.ac.starlink.util
Class ShortList
- java.lang.Object
-
- uk.ac.starlink.util.PrimitiveList
-
- uk.ac.starlink.util.ShortList
-
public class ShortList extends PrimitiveList
Extendable array of shorts.- Since:
- 12 Oct 2006
- Author:
- Mark Taylor
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(short value)
Appends a value to the end of this list.boolean
addAll(ShortList other)
Appends all the elements of a second list to this list.short
get(int i)
Returns the element at a given position.void
set(int i, short value)
Sets the element at a given position.short[]
toShortArray()
Returns the contents of this list as an array.-
Methods inherited from class uk.ac.starlink.util.PrimitiveList
nextCapacity, size, toArray
-
-
-
-
Constructor Detail
-
ShortList
public ShortList()
Constructs a new list.
-
ShortList
public ShortList(int size)
Constructs a new list with a given initial capacity.- Parameters:
size
- initial capacity
-
ShortList
public ShortList(short[] array)
Constructs a new list initialised to the contents of a given array.- Parameters:
array
- array whose contents form initial contents of list
-
-
Method Detail
-
get
public short get(int i)
Returns the element at a given position.- Parameters:
i
- index- Returns:
- element at
i
-
set
public void set(int i, short value)
Sets the element at a given position.- Parameters:
i
- indexvalue
- new value for elementi
-
add
public void add(short value)
Appends a value to the end of this list.- Parameters:
value
- value to append
-
addAll
public boolean addAll(ShortList other)
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
-
toShortArray
public short[] toShortArray()
Returns the contents of this list as an array.- Returns:
- copy of list contents
-
-