public abstract class AbstractLongList extends AbstractLongCollection implements LongList
long
elements.
This class implements Collection
allowing
seamless integration with other APIs.
The get(int)
and size()
methods must be
implemented by subclases.
To make the subclass modifiable, the add(int, long)
,
removeIndex(int)
and set(int, long) must also be implemented.
Subclasses may override other methods to increase efficiency.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractLongList.PListIterator
List iterator.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractLongList()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int index,
long value)
Adds a primitive value to this list at an index (optional operation).
|
void |
add(int index,
java.lang.Long value)
Adds the
Long value to this list at an index (optional operation). |
boolean |
add(long value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(java.lang.Long value)
Adds the
Long value to this collection (optional operation). |
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Long> coll)
Adds an array of
Long values to this list at an index (optional operation). |
boolean |
addAll(int index,
long[] values)
Adds an array of primitive values to this list at an index (optional operation).
|
boolean |
addAll(long[] values)
Adds an array of primitive values to this list at an index (optional operation).
|
protected void |
arrayCopy(int fromIndex,
long[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
protected void |
checkIndex(int index)
Checks whether an index is valid or not.
|
protected void |
checkIndexExists(int index)
Checks whether an index is valid or not.
|
protected void |
checkRange(int fromIndexInclusive,
int toIndexExclusive)
Checks whether a range is valid or not.
|
protected void |
checkSetModifiable()
Check whether add is suported and throw an exception.
|
void |
clear()
Clears the listof all elements (optional operation).
|
boolean |
contains(long value)
Checks whether this collection contains a specified primitive value.
|
boolean |
equals(java.lang.Object obj)
Compares this list to another as per the contract of
List . |
java.lang.Long |
first()
Gets the first
Long value. |
long |
firstLong()
Gets the first primitive value.
|
java.lang.Long |
get(int index)
Gets the
Long value at the specified index. |
int |
hashCode()
Gets the hashCode of this list as per the contract of
List . |
int |
indexOf(long value)
Gets the first index of the specified primitive value.
|
int |
indexOf(long value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
indexOf(java.lang.Object value)
Gets the first index of the specified
Long value. |
int |
indexOf(java.lang.Object value,
int fromIndexInclusive)
Gets the first index of the specified
Long value from an index. |
boolean |
isModifiable()
Is the collection modifiable in any way.
|
protected boolean |
isSetModifiable()
Are the set methods supported.
|
LongListIterator |
iterator()
Gets an iterator over this list.
|
java.lang.Long |
last()
Gets the last
Long value. |
int |
lastIndexOf(long value)
Gets the last index of the specified primitive value.
|
int |
lastIndexOf(long value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
lastIndexOf(java.lang.Object value)
Gets the last index of the specified
Long value. |
int |
lastIndexOf(java.lang.Object value,
int fromIndexInclusive)
Gets the first index of the specified
Long value from an index. |
long |
lastLong()
Gets the last primitive value.
|
LongListIterator |
listIterator()
Gets a list iterator over this list.
|
LongListIterator |
listIterator(int index)
Gets a list iterator over this list from a start index.
|
java.lang.Long |
remove(int index)
Deprecated.
This method should only be used when working with List and
not when working with LongList - use
removeLongAt(int) |
boolean |
removeLong(long value)
Removes the first occurrence of a primitive value from the list (optional operation).
|
long |
removeLongAt(int index)
Removes a primitive value by index from the list (optional operation).
|
boolean |
removeRange(int fromIndexInclusive,
int toIndexExclusive)
Removes a range of values from the list (optional operation).
|
long |
set(int index,
long value)
Sets the primitive value at a specified index.
|
java.lang.Long |
set(int index,
java.lang.Long value)
Sets the
Long value at a specified index. |
LongList |
subList(int fromIndexInclusive,
int toIndexExclusive)
Deprecated.
Not implemented yet.
|
long[] |
toLongArray(int fromIndexInclusive,
int toIndexExclusive)
Gets a range of elements as an array.
|
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isAddModifiable, isRemoveModifiable, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toLongArray, toLongArray, toObject, toPrimitive, toPrimitiveArray, toString
clone, isEmpty, optimize
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
addAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toLongArray, toLongArray
containsAny
clone, isEmpty, optimize, size
public LongListIterator iterator()
iterator
in interface java.lang.Iterable<java.lang.Long>
iterator
in interface java.util.Collection<java.lang.Long>
iterator
in interface java.util.List<java.lang.Long>
iterator
in interface LongCollection
iterator
in interface LongIterable
iterator
in interface LongList
public LongListIterator listIterator()
This implementation uses longListIterator(int)
.
listIterator
in interface java.util.List<java.lang.Long>
listIterator
in interface LongList
public LongListIterator listIterator(int index)
listIterator
in interface java.util.List<java.lang.Long>
listIterator
in interface LongList
index
- the index to start fromjava.lang.IndexOutOfBoundsException
- if the index is invalidpublic long firstLong()
public long lastLong()
public boolean contains(long value)
This implementation uses getLong(int)
.
contains
in interface LongCollection
contains
in class AbstractLongCollection
value
- the value to search fortrue
if the value is foundpublic int indexOf(long value)
This implementation uses indexof(long, int)
.
public int indexOf(long value, int fromIndexInclusive)
This method follows the conventions of String
in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1
.
This implementation uses get(int)
.
public int lastIndexOf(long value)
This implementation uses lastIndexof(long, int)
.
lastIndexOf
in interface LongList
value
- the value to search for-1
if not foundpublic int lastIndexOf(long value, int fromIndexInclusive)
This method follows the conventions of String
in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1
.
This implementation uses get(int)
.
lastIndexOf
in interface LongList
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundpublic long[] toLongArray(int fromIndexInclusive, int toIndexExclusive)
toLongArray
in interface LongList
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusivejava.lang.IndexOutOfBoundsException
- if either index is invalid@Deprecated public LongList subList(int fromIndexInclusive, int toIndexExclusive)
This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.
subList
in interface java.util.List<java.lang.Long>
subList
in interface LongList
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusivejava.lang.UnsupportedOperationException
- alwayspublic void clear()
This implementation uses removeRange(int, int)
.
clear
in interface java.util.Collection<java.lang.Long>
clear
in interface java.util.List<java.lang.Long>
clear
in interface PrimitiveCollectable<java.lang.Long>
clear
in class AbstractLongCollection
java.lang.UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(long value)
This implementation uses add(int, long)
.
add
in interface LongCollection
add
in class AbstractLongCollection
value
- the value to add to this collectiontrue
if this collection was modified by this method calljava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean add(int index, long value)
This implementation throws UnsupportedOperationException.
add
in interface LongList
index
- the index to add atvalue
- the value to add to this collectiontrue
if this list was modified by this method calljava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(long[] values)
This implementation uses addAll(int, long)
.
addAll
in interface LongCollection
addAll
in class AbstractLongCollection
values
- the values to add to this collection, null treated as empty arraytrue
if this list was modified by this method calljava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(int index, long[] values)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll
in interface LongList
index
- the index to add atvalues
- the values to add to this collection, null treated as empty arraytrue
if this list was modified by this method calljava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic long removeLongAt(int index)
This implementation throws UnsupportedOperationException.
removeLongAt
in interface LongList
index
- the index to remove fromjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean removeLong(long value)
This implementation uses get(int)
and removeLongAt(int)
.
value
- the value to removejava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
This implementation uses removeLongAt(int)
.
removeRange
in interface PrimitiveList<java.lang.Long>
fromIndexInclusive
- the start of the range to remove, inclusivetoIndexExclusive
- the end of the range to remove, exclusivetrue
if the collection was modifiedjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.UnsupportedOperationException
- if remove is not supportedpublic long set(int index, long value)
This implementation throws UnsupportedOperationException.
set
in interface LongList
index
- the index to setvalue
- the value to storejava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic java.lang.Long get(int index)
Long
value at the specified index.get
in interface java.util.List<java.lang.Long>
index
- the index to get fromjava.lang.IndexOutOfBoundsException
- if the index is invalidpublic java.lang.Long first()
Long
value.first
in interface PrimitiveList<java.lang.Long>
public java.lang.Long last()
Long
value.last
in interface PrimitiveList<java.lang.Long>
size() - 1
or null if the size is zeropublic int indexOf(java.lang.Object value)
Long
value.indexOf
in interface java.util.List<java.lang.Long>
value
- the value to search for-1
if not foundjava.lang.NullPointerException
- if the value if nulljava.lang.ClassCastException
- if the object is not Long
public int indexOf(java.lang.Object value, int fromIndexInclusive)
Long
value from an index.
This method follows the conventions of String
in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundjava.lang.NullPointerException
- if the value if nulljava.lang.ClassCastException
- if the object is not Long
public int lastIndexOf(java.lang.Object value)
Long
value.lastIndexOf
in interface java.util.List<java.lang.Long>
value
- the value to search for-1
if not foundjava.lang.NullPointerException
- if the value if nulljava.lang.ClassCastException
- if the object is not Long
public int lastIndexOf(java.lang.Object value, int fromIndexInclusive)
Long
value from an index.
This method follows the conventions of String
in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundjava.lang.NullPointerException
- if the value if nulljava.lang.ClassCastException
- if the object is not Long
public boolean add(java.lang.Long value)
Long
value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add
in interface java.util.Collection<java.lang.Long>
add
in interface java.util.List<java.lang.Long>
add
in class AbstractLongCollection
value
- the value to add to this collectiontrue
if this collection was modified by this method calljava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic void add(int index, java.lang.Long value)
Long
value to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add
in interface java.util.List<java.lang.Long>
index
- the index to add atvalue
- the value to add to this collectionjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.ClassCastException
- if the object is not Long
java.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(int index, java.util.Collection<? extends java.lang.Long> coll)
Long
values to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll
in interface java.util.List<java.lang.Long>
index
- the index to add atcoll
- the values to add to this collectiontrue
if this list was modified by this method calljava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.ClassCastException
- if any object is not Long
java.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collection@Deprecated public java.lang.Long remove(int index)
removeLongAt(int)
This implementation uses removeLongAt(int)
.
remove
in interface java.util.List<java.lang.Long>
remove
in interface LongList
index
- the index to remove fromjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic java.lang.Long set(int index, java.lang.Long value)
Long
value at a specified index.
This implementation uses set(int, long)
.
set
in interface java.util.List<java.lang.Long>
index
- the index to setvalue
- the value to storejava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.IllegalArgumentException
- if value is rejected by this collectionjava.lang.UnsupportedOperationException
- if not supported by this collectionpublic boolean equals(java.lang.Object obj)
List
.equals
in interface java.util.Collection<java.lang.Long>
equals
in interface java.util.List<java.lang.Long>
equals
in class java.lang.Object
obj
- the object to compare totrue
if the lists are equalpublic int hashCode()
List
.hashCode
in interface java.util.Collection<java.lang.Long>
hashCode
in interface java.util.List<java.lang.Long>
hashCode
in class java.lang.Object
protected void arrayCopy(int fromIndex, long[] dest, int destIndex, int size)
arrayCopy
in class AbstractLongCollection
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected boolean isSetModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<java.lang.Long>
isModifiable
in class AbstractLongCollection
protected void checkSetModifiable()
protected void checkIndexExists(int index)
index
- the index to checkjava.lang.IndexOutOfBoundsException
- if either index is invalidprotected void checkIndex(int index)
index
- the index to checkjava.lang.IndexOutOfBoundsException
- if either index is invalidprotected void checkRange(int fromIndexInclusive, int toIndexExclusive)
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusivejava.lang.IndexOutOfBoundsException
- if either index is invalidCopyright © 2005–2018 Joda.org. All rights reserved.