E
- the type of content of this Listpublic class ImmutableVector<E> extends ImmutableAbstractList<E>
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.
Constructor and Description |
---|
ImmutableVector(ImmutableList<E> list) |
ImmutableVector(ImmutableList<E> list,
Immutable copyOrWrap) |
ImmutableVector(List<E> list) |
ImmutableVector(List<E> list,
Immutable copyOrWrap) |
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Returns the current capacity of this immutable vector.
|
void |
copyInto(Object[] anArray)
Copies the components of this immutable vector into the specified array.
|
E |
elementAt(int index)
Returns the component at the specified index.
|
Enumeration<E> |
elements()
Returns an enumeration of the components of this vector.
|
E |
firstElement()
Returns the first component (the item at index
0 ) of this immutable vector. |
protected Vector<E> |
getList()
Prepare the list of the right type for use a subclass.
|
int |
indexOf(Object o,
int index)
Returns the index of the first occurrence of the specified element in this immutable vector, searching forwards from
index , or returns -1 if the element is not found. |
E |
lastElement()
Returns the last component of the immutable vector.
|
int |
lastIndexOf(Object o,
int index)
Returns the index of the last occurrence of the specified element in this immutable vector, searching backwards from
index , or returns -1 if the element is not found. |
ImmutableList<E> |
subList(int fromIndex,
int toIndex)
Returns a safe, immutable copy of the portion of this immutable list between the specified fromIndex, inclusive,
and toIndex, exclusive.
|
List<E> |
toList()
Returns a modifiable copy of this immutable list.
|
String |
toString() |
contains, containsAll, containsAll, equals, forEach, get, hashCode, indexOf, isEmpty, isWrap, iterator, lastIndexOf, parallelStream, size, spliterator, stream, toArray, toArray, toCollection
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isCopy
public ImmutableVector(List<E> list)
list
- the list to use as the immutable list.public ImmutableVector(List<E> list, Immutable copyOrWrap)
list
- the list to use as the immutable vector.copyOrWrap
- COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionpublic ImmutableVector(ImmutableList<E> list)
list
- the list to use as the immutable list.public ImmutableVector(ImmutableList<E> list, Immutable copyOrWrap)
list
- the list to use as the immutable list.copyOrWrap
- COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionprotected final Vector<E> getList()
@Override protected ArrayList<E> getList() { return (ArrayList<E>) super.getList(); }
getList
in class ImmutableAbstractList<E>
public final List<E> toList()
public final ImmutableList<E> subList(int fromIndex, int toIndex)
fromIndex
- low endpoint (inclusive) of the subListtoIndex
- high endpoint (exclusive) of the subListpublic final void copyInto(Object[] anArray)
k
in this immutable
vector is copied into component k
of anArray
.anArray
- the array into which the components get copiedNullPointerException
- if the given array is nullIndexOutOfBoundsException
- if the specified array is not large enough to hold all the components of this immutable
vectorArrayStoreException
- if a component of this immutable vector is not of a runtime type that can be stored in the
specified arrayImmutableAbstractList.toArray(Object[])
public final int capacity()
public final Enumeration<E> elements()
Enumeration
object will generate all items
in this vector. The first item generated is the item at index 0
, then the item at index 1
, and so on.Iterator
public final int indexOf(Object o, int index)
index
, or returns -1 if the element is not found. More formally, returns the lowest index i
such that
(i >= index && (o==null ? get(i)==null : o.equals(get(i)))),
or -1 if there is no such index.o
- element to search forindex
- index to start searching fromindex
or later in
the vector; -1
if the element is not found.IndexOutOfBoundsException
- if the specified index is negativeObject.equals(Object)
public final int lastIndexOf(Object o, int index)
index
, or returns -1 if the element is not found. More formally, returns the highest index i
such that
(i <= index && (o==null ? get(i)==null : o.equals(get(i)))),
or -1 if there is no such index.o
- element to search forindex
- index to start searching backwards fromindex
in this immutable
vector; -1 if the element is not found.IndexOutOfBoundsException
- if the specified index is greater than or equal to the current size of this immutable
vectorpublic final E elementAt(int index)
This method is identical in functionality to the ImmutableAbstractList.get(int)
method (which is part of the List
interface).
index
- an index into this immutable vectorArrayIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)public final E firstElement()
0
) of this immutable vector.NoSuchElementException
- if this immutable vector has no componentspublic final E lastElement()
size() - 1
.NoSuchElementException
- if this immutable vector is emptypublic final String toString()
toString
in class ImmutableAbstractList<E>
Copyright © 2014–2016 Delft University of Technology. All rights reserved.