public static class LongLists.Singleton extends AbstractLongList implements RandomAccess, Serializable, Cloneable
This class may be useful to implement your own in case you subclass a type-specific list.
AbstractLongList.LongSubList| Modifier and Type | Method and Description |
|---|---|
boolean |
addAll(Collection<? extends Long> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
boolean |
addAll(int i,
Collection<? extends Long> c)
Adds all of the elements in the specified collection to this list
(optional operation).
|
boolean |
addAll(int i,
LongCollection c)
Inserts all of the elements in the specified type-specific collection
into this type-specific list at the specified position (optional
operation).
|
boolean |
addAll(int i,
LongList c)
Inserts all of the elements in the specified type-specific list into this
type-specific list at the specified position (optional operation).
|
boolean |
addAll(LongCollection c)
Adds all elements of the given type-specific collection to this
collection.
|
boolean |
addAll(LongList c)
Appends all of the elements in the specified type-specific list to the
end of this type-specific list (optional operation).
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
Object |
clone()
Creates and returns a copy of this object.
|
boolean |
contains(long k)
Returns true if this list contains the specified element.
|
long |
getLong(int i)
Returns the element at the specified position in this list.
|
LongListIterator |
iterator()
Returns an iterator over the elements contained in this collection.
|
LongListIterator |
listIterator()
Returns a type-specific list iterator on the list.
|
LongListIterator |
listIterator(int i)
Returns a type-specific list iterator on the list starting at a given
index.
|
boolean |
rem(long k)
Removes a single instance of the specified element from this collection,
if it is present (optional operation).
|
boolean |
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
boolean |
removeAll(LongCollection c)
Remove from this collection all elements in the given type-specific
collection.
|
long |
removeLong(int i)
Removes the element at the specified position in this list (optional
operation).
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(LongCollection c)
Retains in this collection only elements from the given type-specific
collection.
|
int |
size()
Returns the number of elements in this collection.
|
void |
size(int size)
Sets the size of this list.
|
LongList |
subList(int from,
int to)
Returns a type-specific view of the portion of this list from the index
from, inclusive, to the index to, exclusive. |
long[] |
toLongArray()
Returns a primitive type array containing the items of this collection.
|
add, add, add, addElements, addElements, compareTo, equals, get, getElements, hashCode, indexOf, indexOf, lastIndexOf, lastIndexOf, peek, peekLong, pop, popLong, push, push, remove, removeElements, set, set, top, topLong, toStringadd, contains, containsAll, remove, toArray, toLongArraycontainsAll, isEmpty, toArray, toArraycontains, containsAll, isEmpty, remove, replaceAll, sort, spliterator, toArray, toArraycontains, containsAll, remove, toArray, toLongArrayparallelStream, removeIf, streamforEach, forEachpublic long getLong(int i)
LongListgetLong in interface LongListList.get(int)public boolean rem(long k)
AbstractLongList
This implementation delegates to indexOf().
rem in interface LongCollectionrem in class AbstractLongListList.remove(Object)public long removeLong(int i)
AbstractLongList
This implementation always throws an
UnsupportedOperationException.
removeLong in interface LongListremoveLong in class AbstractLongListList.remove(int)public boolean contains(long k)
AbstractLongList
This implementation delegates to indexOf().
contains in interface LongCollectioncontains in class AbstractLongListList.contains(Object)public long[] toLongArray()
LongCollectiontoLongArray in interface LongCollectiontoLongArray in class AbstractLongCollectionCollection.toArray()public LongListIterator listIterator()
AbstractLongList
This implementation delegates to listIterator(0).
listIterator in interface LongListlistIterator in interface List<Long>listIterator in class AbstractLongListList.listIterator()public LongListIterator iterator()
AbstractLongList
This implementation delegates to AbstractLongList.listIterator().
iterator in interface LongCollectioniterator in interface LongIterableiterator in interface LongListiterator in interface Iterable<Long>iterator in interface Collection<Long>iterator in interface List<Long>iterator in class AbstractLongListIterable.iterator()public LongListIterator listIterator(int i)
AbstractLongListThis implementation is based on the random-access methods.
listIterator in interface LongListlistIterator in interface List<Long>listIterator in class AbstractLongListi - index of the first element to be returned from the
list iterator (by a call to next)List.listIterator(int)public LongList subList(int from, int to)
LongListfrom, inclusive, to the index to, exclusive.
Note that this specification strengthens the one given in
List.subList(int,int).
subList in interface LongListsubList in interface List<Long>subList in class AbstractLongListfrom - low endpoint (inclusive) of the subListto - high endpoint (exclusive) of the subListList.subList(int,int)public boolean addAll(int i,
Collection<? extends Long> c)
AbstractLongListaddAll in interface List<Long>addAll in class AbstractLongListi - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listpublic boolean addAll(Collection<? extends Long> c)
AbstractLongListThis implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll in interface Collection<Long>addAll in interface List<Long>addAll in class AbstractLongListc - collection containing elements to be added to this collectionAbstractCollection.add(Object)public boolean removeAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.
removeAll in interface Collection<Long>removeAll in interface List<Long>removeAll in class AbstractCollection<Long>c - collection containing elements to be removed from this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean retainAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll in interface Collection<Long>retainAll in interface List<Long>retainAll in class AbstractCollection<Long>c - collection containing elements to be retained in this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean addAll(LongList c)
AbstractLongList
This implementation delegates to the type-specific list version of
List.addAll(int, Collection).
addAll in interface LongListaddAll in class AbstractLongListList.add(int,Object)public boolean addAll(int i,
LongList c)
AbstractLongList
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll in interface LongListaddAll in class AbstractLongListList.add(int,Object)public boolean addAll(int i,
LongCollection c)
LongListaddAll in interface LongListaddAll in class AbstractLongListList.addAll(int,java.util.Collection)public boolean addAll(LongCollection c)
AbstractLongList
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll in interface LongCollectionaddAll in class AbstractLongListc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)public boolean removeAll(LongCollection c)
LongCollectionremoveAll in interface LongCollectionremoveAll in class AbstractLongCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)public boolean retainAll(LongCollection c)
LongCollectionretainAll in interface LongCollectionretainAll in class AbstractLongCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)public int size()
java.util.Collectionsize in interface Collection<Long>size in interface List<Long>size in class AbstractCollection<Long>public void size(int size)
LongList
If the specified size is smaller than the current size, the last elements
are discarded. Otherwise, they are filled with
0/null/false.
size in interface LongListsize in class AbstractLongListsize - the new size.public void clear()
AbstractLongListThis implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.
This implementation delegates to AbstractLongList.removeElements(int, int).
clear in interface Collection<Long>clear in interface List<Long>clear in class AbstractLongListpublic Object clone()
java.lang.Objectx, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except
Object) obey this convention, it will be the case that
x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone for class Object performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable, then a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable and that
the return type of the clone method of an array type T[]
is T[] where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time.