Class Vector<E>
java.lang.Object
com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractList<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractIndexedList<E>
com.github.andrewoma.dexx.collection.Vector<E>
- All Implemented Interfaces:
IndexedList<E>,Iterable<E>,List<E>,Traversable<E>,Iterable<E>
Vector is a general-purpose, immutable data structure.
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final Vectorprivate final intprivate final intprotected final VectorPointer<E> private final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a list with the specified element appended to the bottom of the list.private intcheckRangeConvert(int index) private voidcleanLeftEdge(int cutIndex) private voidcleanRightEdge(int cutIndex) private Object[]private Object[]drop(int n) Returns a list containing all elements in this list, excluding the firstnumberof elements.dropBack0(int cutIndex) dropFront0(int cutIndex) static <E> @NotNull Vector<E> empty()static <E> @NotNull BuilderFactory<E, Vector<E>> factory()first()Returns first element in the list ornullif the list is empty.get(int index) Returns the element at the specified index in this list (zero-based).private voidgotoFreshPosWritable(int oldIndex, int newIndex, int xor) private voidgotoPosWritable(int oldIndex, int newIndex, int xor) private voidbooleanisEmpty()Returns true if this collection is empty.iterator()last()Returns last element in the list ornullif the list is empty.private voidpreClean(int depth) Returns a list with the specified element prepended to the top of the list.range(int from, boolean fromInclusive, int to, boolean toInclusive) Returns a list containing a contiguous range of elements from this list.private intrequiredDepth(int xor) Returns a list with the element set to the value specified at the index (zero-based).private voidshiftTopLevel(int oldLeft, int newLeft) intsize()Returns the size of the collection.slice(int from, int until) splitAt(int n) tail()Returns a list containing all elements in the list, excluding the first element.take(int n) Returns a list containing the firstnumberof elements from this list.private voidprivate voidMethods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractList
asList, equals, hashCode, indexOf, lastIndexOfMethods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractIterable
forEachMethods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable
makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.github.andrewoma.dexx.collection.List
asList, indexOf, lastIndexOfMethods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
Field Details
-
EMPTY
-
pointer
-
startIndex
private final int startIndex -
endIndex
private final int endIndex -
focus
private final int focus -
dirty
private boolean dirty
-
-
Constructor Details
-
Vector
Vector(int startIndex, int endIndex, int focus)
-
-
Method Details
-
factory
-
empty
-
size
public int size()Description copied from interface:TraversableReturns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
sizein interfaceTraversable<E>- Overrides:
sizein classAbstractTraversable<E>
-
initIterator
-
iterator
-
get
Description copied from interface:ListReturns the element at the specified index in this list (zero-based). -
checkRangeConvert
private int checkRangeConvert(int index) -
take
Description copied from interface:ListReturns a list containing the firstnumberof elements from this list. -
drop
Description copied from interface:ListReturns a list containing all elements in this list, excluding the firstnumberof elements. -
isEmpty
public boolean isEmpty()Description copied from interface:TraversableReturns true if this collection is empty.- Specified by:
isEmptyin interfaceTraversable<E>- Overrides:
isEmptyin classAbstractTraversable<E>
-
first
Description copied from interface:ListReturns first element in the list ornullif the list is empty. -
tail
Description copied from interface:ListReturns a list containing all elements in the list, excluding the first element. An empty list is returned if the list is empty. -
last
Description copied from interface:ListReturns last element in the list ornullif the list is empty. -
range
@NotNull public @NotNull Vector<E> range(int from, boolean fromInclusive, int to, boolean toInclusive) Description copied from interface:ListReturns a list containing a contiguous range of elements from this list.- Parameters:
from- starting index for the range (zero-based)fromInclusive- if true, the element at thefromindex will be includedto- end index for the range (zero-based)toInclusive- if true, the element at thetoindex will be included
-
slice
-
splitAt
-
set
Description copied from interface:ListReturns a list with the element set to the value specified at the index (zero-based). -
gotoPosWritable
private void gotoPosWritable(int oldIndex, int newIndex, int xor) -
gotoFreshPosWritable
private void gotoFreshPosWritable(int oldIndex, int newIndex, int xor) -
prepend
Description copied from interface:ListReturns a list with the specified element prepended to the top of the list. -
append
Description copied from interface:ListReturns a list with the specified element appended to the bottom of the list. -
shiftTopLevel
private void shiftTopLevel(int oldLeft, int newLeft) -
zeroLeft
-
zeroRight
-
copyLeft
-
copyRight
-
preClean
private void preClean(int depth) -
cleanLeftEdge
private void cleanLeftEdge(int cutIndex) -
cleanRightEdge
private void cleanRightEdge(int cutIndex) -
requiredDepth
private int requiredDepth(int xor) -
dropFront0
-
dropBack0
-