- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.pcollections.AbstractUnmodifiableList<E>
-
- org.pcollections.TreePVector<E>
-
- Type Parameters:
E-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>,PCollection<E>,PSequence<E>,PVector<E>
public class TreePVector<E> extends AbstractUnmodifiableList<E> implements PVector<E>, java.io.Serializable
A persistent vector of elements.This implementation is backed by an IntTreePMap and supports logarithmic-time querying, setting, insertion, and removal.
This implementation is thread-safe (assuming Java's AbstractList is thread-safe) although its iterators may not be.
Null values are supported.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static TreePVector<java.lang.Object>EMPTYprivate IntTreePMap<E>mapprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description privateTreePVector(IntTreePMap<E> map)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> TreePVector<E>empty()static <E> TreePVector<E>from(java.util.Collection<? extends E> list)Eget(int index)java.util.Iterator<E>iterator()TreePVector<E>minus(int i)TreePVector<E>minus(java.lang.Object e)Returns a sequence consisting of the elements of this without the first occurrence of e.TreePVector<E>minusAll(java.util.Collection<?> list)TreePVector<E>plus(int i, E e)TreePVector<E>plus(E e)Returns a vector consisting of the elements of this with e appended.TreePVector<E>plusAll(int i, java.util.Collection<? extends E> list)TreePVector<E>plusAll(java.util.Collection<? extends E> list)Returns a vector consisting of the elements of this with list appended.static <E> TreePVector<E>singleton(E e)intsize()TreePVector<E>subList(int start, int end)PVector<E>with(int i, E e)-
Methods inherited from class org.pcollections.AbstractUnmodifiableList
add, add, addAll, addAll, clear, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sort
-
Methods inherited from class java.util.AbstractList
equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
EMPTY
private static final TreePVector<java.lang.Object> EMPTY
-
map
private final IntTreePMap<E> map
-
-
Constructor Detail
-
TreePVector
private TreePVector(IntTreePMap<E> map)
-
-
Method Detail
-
empty
public static <E> TreePVector<E> empty()
- Type Parameters:
E-- Returns:
- an empty vector
-
singleton
public static <E> TreePVector<E> singleton(E e)
- Type Parameters:
E-- Parameters:
e-- Returns:
- empty().plus(e)
-
from
public static <E> TreePVector<E> from(java.util.Collection<? extends E> list)
- Type Parameters:
E-- Parameters:
list-- Returns:
- empty().plusAll(list)
-
size
public int size()
-
get
public E get(int index)
-
iterator
public java.util.Iterator<E> iterator()
-
subList
public TreePVector<E> subList(int start, int end)
-
plus
public TreePVector<E> plus(E e)
Description copied from interface:PVectorReturns a vector consisting of the elements of this with e appended.
-
plus
public TreePVector<E> plus(int i, E e)
-
minus
public TreePVector<E> minus(java.lang.Object e)
Description copied from interface:PSequenceReturns a sequence consisting of the elements of this without the first occurrence of e.
-
minus
public TreePVector<E> minus(int i)
-
plusAll
public TreePVector<E> plusAll(java.util.Collection<? extends E> list)
Description copied from interface:PVectorReturns a vector consisting of the elements of this with list appended.
-
minusAll
public TreePVector<E> minusAll(java.util.Collection<?> list)
-
plusAll
public TreePVector<E> plusAll(int i, java.util.Collection<? extends E> list)
-
-