public class Vector<E> extends AbstractIndexedList<E>
It provides random access and updates in effectively constant time, as well as very fast append and prepend.
It is backed by a little endian bit-mapped vector trie with a branching factor of 32. Locality is very good, but not contiguous, which is good for very large sequences.
See Scala's documentation for more information on the implementation.
| Modifier and Type | Field and Description |
|---|---|
protected com.github.andrewoma.dexx.collection.VectorPointer<E> |
pointer |
| Modifier and Type | Method and Description |
|---|---|
Vector<E> |
append(E value)
Returns a list with the specified element appended to the bottom of the list.
|
Vector<E> |
drop(int n)
Returns a list containing all elements in this list, excluding the first
number of elements. |
static <E> Vector<E> |
empty() |
static <E> BuilderFactory<E,Vector<E>> |
factory() |
E |
first()
Returns first element in the list or
null if the list is empty. |
E |
get(int index)
Returns the element at the specified index in this list (zero-based).
|
boolean |
isEmpty()
Returns true if this collection is empty.
|
java.util.Iterator<E> |
iterator() |
E |
last()
Returns last element in the list or
null if the list is empty. |
Vector<E> |
prepend(E value)
Returns a list with the specified element prepended to the top of the list.
|
Vector<E> |
range(int from,
boolean fromInclusive,
int to,
boolean toInclusive)
Returns a list containing a contiguous range of elements from this list.
|
Vector<E> |
set(int index,
E elem)
Returns a list with the element set to the value specified at the index (zero-based).
|
int |
size()
Returns the size of the collection.
|
protected Pair<Vector<E>,Vector<E>> |
splitAt(int n) |
Vector<E> |
tail()
Returns a list containing all elements in the list, excluding the first element.
|
Vector<E> |
take(int n)
Returns a list containing the first
number of elements from this list. |
asList, equals, hashCode, indexOf, lastIndexOfforEachmakeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasList, indexOf, lastIndexOfforEach, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSetprotected final com.github.andrewoma.dexx.collection.VectorPointer<E> pointer
@NotNull public static <E> BuilderFactory<E,Vector<E>> factory()
@NotNull public static <E> Vector<E> empty()
public int size()
TraversableWarning: infinite collections are possible, as are collections that require traversal to calculate the size.
size in interface Traversable<E>size in class AbstractTraversable<E>@NotNull public java.util.Iterator<E> iterator()
public E get(int index)
List@NotNull public Vector<E> take(int n)
Listnumber of elements from this list.@NotNull public Vector<E> drop(int n)
Listnumber of elements.public boolean isEmpty()
TraversableisEmpty in interface Traversable<E>isEmpty in class AbstractTraversable<E>@Nullable public E first()
Listnull if the list is empty.@NotNull public Vector<E> tail()
List@Nullable public E last()
Listnull if the list is empty.@NotNull public Vector<E> range(int from, boolean fromInclusive, int to, boolean toInclusive)
Listfrom - starting index for the range (zero-based)fromInclusive - if true, the element at the from index will be includedto - end index for the range (zero-based)toInclusive - if true, the element at the to index will be included@NotNull public Vector<E> set(int index, E elem)
List@NotNull public Vector<E> prepend(E value)
List