E - the type of content of this Listpublic abstract class ImmutableAbstractList<E> extends Object implements ImmutableList<E>, RandomAccess
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
| Modifier | Constructor and Description |
|---|---|
protected |
ImmutableAbstractList(List<E> list,
boolean copy)
Construct an abstract immutable list.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Object o)
Returns true if this immutable collection contains the specified element.
|
boolean |
containsAll(Collection<?> c)
Returns true if this immutable collection contains all of the elements in the specified collection.
|
boolean |
containsAll(ImmutableCollection<?> c)
Returns true if this immutable collection contains all of the elements in the specified immutable collection.
|
boolean |
equals(Object obj)
Force to redefine equals for the implementations of immutable collection classes.
|
void |
forEach(Consumer<? super E> action) |
E |
get(int index)
Returns the element at the specified position in this immutable list.
|
protected List<E> |
getList()
Prepare the list of the right type for use a subclass.
|
int |
hashCode()
Force to redefine hashCode for the implementations of immutable collection classes.
|
int |
indexOf(Object o)
Returns the index of the first occurrence of the specified element in this immutable list, or -1 if this immutable list
does not contain the element.
|
boolean |
isEmpty()
Returns true if this immutable collection contains no elements.
|
boolean |
isWrap()
Return whether the internal storage is a wrapped pointer to the original collection.
|
ImmutableIterator<E> |
iterator()
Returns an immutable iterator over the elements in this immutable collection.
|
int |
lastIndexOf(Object o)
Returns the index of the last occurrence of the specified element in this immutable list, or -1 if this immutable list
does not contain the element.
|
Stream<E> |
parallelStream()
Returns a possibly parallel
Stream with this collection as its source. |
int |
size()
Returns the number of elements in this immutable collection.
|
Spliterator<E> |
spliterator()
Creates a Spliterator over the elements in this collection.
|
Stream<E> |
stream()
Returns a sequential
Stream with this collection as its source. |
Object[] |
toArray()
Returns an array containing all of the elements in this immutable collection.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this immutable collection; the runtime type of the returned array is
that of the specified array.
|
Collection<E> |
toCollection()
Returns a modifiable copy of this immutable collection.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitsubList, toListisCopyprotected ImmutableAbstractList(List<E> list, boolean copy)
list - a safe copy of the list, or pointer to the list to use as the immutable listcopy - indicate whether the immutable is a copy or a wrapprotected List<E> getList()
@Override
protected ArrayList<E> getList()
{
return (ArrayList<E>) super.getList();
}
public final Collection<E> toCollection()
toCollection in interface ImmutableCollection<E>public final int size()
size in interface ImmutableCollection<E>public final boolean isEmpty()
isEmpty in interface ImmutableCollection<E>public final boolean contains(Object o)
contains in interface ImmutableCollection<E>o - element whose presence in this immutable collection is to be testedpublic final int indexOf(Object o)
indexOf in interface ImmutableList<E>o - element to search forpublic final int lastIndexOf(Object o)
lastIndexOf in interface ImmutableList<E>o - element to search forpublic final Object[] toArray()
See java.util.Collection.toArray() for more details.
toArray in interface ImmutableCollection<E>public final <T> T[] toArray(T[] a)
See java.util.Collection.toArray(T[]) for more details.
toArray in interface ImmutableCollection<E>T - the runtime type of the array to contain the immutable collectiona - the array into which the elements of this immutable collection are to be stored, if it is big enough; otherwise,
a new array of the same runtime type is allocated for this purpose.public final E get(int index)
get in interface ImmutableList<E>index - index of the element to returnpublic final ImmutableIterator<E> iterator()
public final Spliterator<E> spliterator()
spliterator in interface Iterable<E>spliterator in interface ImmutableCollection<E>Spliterator over the elements in this collectionpublic final boolean containsAll(Collection<?> c)
containsAll in interface ImmutableCollection<E>c - collection to be checked for containment in this immutable collectionImmutableCollection.contains(Object)public final boolean containsAll(ImmutableCollection<?> c)
containsAll in interface ImmutableCollection<E>c - immutable collection to be checked for containment in this immutable collectionImmutableCollection.contains(Object)public final Stream<E> stream()
Stream with this collection as its source.
This method should be overridden when the ImmutableCollection.spliterator() method cannot return a spliterator that is
IMMUTABLE, CONCURRENT, or late-binding. (See ImmutableCollection.spliterator() for details.)
stream in interface ImmutableCollection<E>Stream over the elements in this collectionpublic final Stream<E> parallelStream()
Stream with this collection as its source. It is allowable for this method to return
a sequential stream.
This method should be overridden when the ImmutableCollection.spliterator() method cannot return a spliterator that is
IMMUTABLE, CONCURRENT, or late-binding. (See ImmutableCollection.spliterator() for details.)
parallelStream in interface ImmutableCollection<E>Stream over the elements in this collectionpublic final boolean isWrap()
isWrap in interface ImmutableCollection<E>public int hashCode()
hashCode in interface ImmutableCollection<E>hashCode in interface ImmutableList<E>hashCode in class Objectpublic boolean equals(Object obj)
equals in interface ImmutableCollection<E>equals in interface ImmutableList<E>equals in class Objectobj - the object to compare this collection withCopyright © 2014–2016 Delft University of Technology. All rights reserved.