public class ArrayLongList extends AbstractLongList implements Cloneable
LongList
for
primitive int
elements.
This class implements List
allowing
seamless integration with other APIs.
Add, Remove, Set and Clear are supported.
AbstractLongList.PListIterator
Constructor and Description |
---|
ArrayLongList()
Constructor.
|
ArrayLongList(Collection<Long> coll)
Constructor that copies the specified values.
|
ArrayLongList(int initialSize)
Constructor that defines an initial size for the internal storage array.
|
ArrayLongList(long[] values)
Constructor that copies the specified values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int index,
long value)
Adds a primitive value to this collection.
|
boolean |
addAll(int index,
long[] values)
Adds an array of primitive values to this collection at a specified index.
|
protected void |
arrayCopy(int fromIndex,
long[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
void |
clear()
Clears the collection/map of all elements.
|
Object |
clone()
Clone implementation that calls Object clone().
|
boolean |
contains(long value)
Checks whether this collection contains a specified primitive value.
|
protected void |
ensureCapacity(int capacity)
Ensures that the internal storage array has at least the specified size.
|
long |
getLong(int index)
Gets the primitive value at the specified index.
|
protected boolean |
isAddModifiable()
Are the add methods supported.
|
boolean |
isModifiable()
Checks whether the object can currently be modified.
|
protected boolean |
isRemoveModifiable()
Are the remove methods supported.
|
protected boolean |
isSetModifiable()
Are the remove methods supported.
|
void |
optimize()
Optimizes the implementation.
|
long |
removeLongAt(int index)
Removes a primitive value by index from the list.
|
boolean |
removeRange(int fromIndexInclusive,
int toIndexExclusive)
Removes a range of values from the list.
|
long |
set(int index,
long value)
Sets the primitive value at a specified index.
|
int |
size()
Gets the current size of the collection.
|
add, add, add, addAll, addAll, checkIndex, checkIndexExists, checkRange, checkSetModifiable, equals, first, firstLong, get, hashCode, indexOf, indexOf, indexOf, indexOf, iterator, last, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastLong, listIterator, listIterator, remove, removeLong, set, subList, toLongArray
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toLongArray, toLongArray, toObject, toPrimitive, toPrimitiveArray, toString
isEmpty
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
addAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toLongArray, toLongArray
containsAny
isEmpty
public ArrayLongList()
public ArrayLongList(int initialSize)
initialSize
- the initial size of the internal array, negative treated as zeropublic ArrayLongList(long[] values)
values
- an array of values to copy, null treated as zero size arraypublic ArrayLongList(Collection<Long> coll)
coll
- a collection of values to copy, null treated as zero size collectionpublic int size()
size
in interface Collection<Long>
size
in interface List<Long>
size
in interface PrimitiveCollectable<Long>
public long getLong(int index)
getLong
in interface LongList
index
- the index to get fromIndexOutOfBoundsException
- if the index is invalidpublic boolean add(int index, long value)
add
in interface LongList
add
in class AbstractLongList
index
- the index to insert atvalue
- the value to add to this collectiontrue
if this collection was modified by this method callIndexOutOfBoundsException
- if the index is invalidpublic long removeLongAt(int index)
removeLongAt
in interface LongList
removeLongAt
in class AbstractLongList
index
- the index to remove fromIndexOutOfBoundsException
- if the index is invalidpublic boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
removeRange
in interface PrimitiveList<Long>
removeRange
in class AbstractLongList
fromIndexInclusive
- the start of the range to remove, inclusivetoIndexExclusive
- the end of the range to remove, exclusivetrue
if the collection was modifiedpublic long set(int index, long value)
set
in interface LongList
set
in class AbstractLongList
index
- the index to setvalue
- the value to storeIndexOutOfBoundsException
- if the index is invalidpublic void optimize()
This implementation changes the internal array to be the same size as the size of the collection.
optimize
in interface PrimitiveCollectable<Long>
optimize
in class AbstractPrimitiveCollectable<Long>
public void clear()
This implementation resets the size, but does not reduce the internal storage array.
The collection/map will have a zero size after this method completes.
clear
in interface Collection<Long>
clear
in interface List<Long>
clear
in interface PrimitiveCollectable<Long>
clear
in class AbstractLongList
public boolean contains(long value)
This implementation accesses the internal storage array directly.
contains
in interface LongCollection
contains
in class AbstractLongList
value
- the value to search fortrue
if the value is foundpublic boolean addAll(int index, long[] values)
addAll
in interface LongList
addAll
in class AbstractLongList
index
- the index to add atvalues
- the values to add to this collectiontrue
if this collection was modified by this method callIndexOutOfBoundsException
- if the index is invalidprotected boolean isAddModifiable()
isAddModifiable
in class AbstractLongCollection
true
protected boolean isRemoveModifiable()
isRemoveModifiable
in class AbstractLongCollection
true
protected boolean isSetModifiable()
isSetModifiable
in class AbstractLongList
true
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Long>
isModifiable
in class AbstractLongList
true
public Object clone()
clone
in interface PrimitiveCollectable<Long>
clone
in class AbstractPrimitiveCollectable<Long>
protected void arrayCopy(int fromIndex, long[] dest, int destIndex, int size)
arrayCopy
in class AbstractLongList
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected void ensureCapacity(int capacity)
capacity
- the amount to expand toCopyright © 2005-2012 Joda.org. All Rights Reserved.