E - the type of content of this Listpublic class ImmutableVector<E> extends ImmutableAbstractList<E>
Copyright (c) 2016-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
copyOrWrap| Constructor and Description |
|---|
ImmutableVector(Collection<? extends E> collection) |
ImmutableVector(ImmutableAbstractCollection<? extends E> collection) |
ImmutableVector(ImmutableVector<E> vector,
Immutable copyOrWrap) |
ImmutableVector(Vector<E> vector,
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> |
getCollection()
Returns the underlying collection of this immutable collection.
|
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() |
Vector<E> |
toVector()
Returns a modifiable copy of this immutable vector.
|
contains, containsAll, containsAll, equals, forEach, get, hashCode, indexOf, isEmpty, isWrap, iterator, lastIndexOf, parallelStream, size, spliterator, stream, toArray, toArray, toCollectionclone, finalize, getClass, notify, notifyAll, wait, wait, waitisCopypublic ImmutableVector(Collection<? extends E> collection)
collection - Collection<? extends E>; the collection to use for the immutable vector.public ImmutableVector(Vector<E> vector, Immutable copyOrWrap)
vector - Vector<E>; the vector to use for the immutable vector.copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionpublic ImmutableVector(ImmutableAbstractCollection<? extends E> collection)
collection - ImmutableAbstractCollection<? extends E>; the immutable collection to use for the immutable
vector.public ImmutableVector(ImmutableVector<E> vector, Immutable copyOrWrap)
vector - ImmutableVector<E>; the vector to use for the immutable vector.copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionpublic final List<E> toList()
public final Vector<E> toVector()
protected Vector<E> getCollection()
getCollection in class ImmutableAbstractList<E>public final ImmutableList<E> subList(int fromIndex, int toIndex)
fromIndex - int; low endpoint (inclusive) of the subListtoIndex - int; high endpoint (exclusive) of the subListpublic final void copyInto(Object[] anArray)
k in this immutable
vector is copied into component k of anArray.anArray - Object[]; 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.Iteratorpublic 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 - Object; element to search forindex - int; 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 - Object; element to search forindex - int; 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 - int; 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 © 2018–2019 Delft University of Technology. All rights reserved.