Class ConsPStack<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
org.pcollections.AbstractUnmodifiableSequentialList<E>
org.pcollections.ConsPStack<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, PCollection<E>, PSequence<E>, PStack<E>
public final class ConsPStack<E>
extends AbstractUnmodifiableSequentialList<E>
implements PStack<E>, Serializable
A simple persistent stack.
This implementation is thread-safe (assuming Java's AbstractSequentialList is thread-safe), although its iterators may not be.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConsPStack<Object> / STATIC FACTORY METHODS ////private final E/ PRIVATE CONSTRUCTORS ////private final ConsPStack<E> private static final longprivate final intFields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> ConsPStack<E> empty()static <E> ConsPStack<E> from(Collection<? extends E> list) private static <E> ConsPStack<E> listIterator(int index) minus(int i) Returns a sequence consisting of the elements of this without the first occurrence of e.minusAll(Collection<?> list) / IMPLEMENTED METHODS OF PStack ////plusAll(int i, Collection<? extends E> list) plusAll(Collection<? extends E> list) Returns a stack consisting of the elements of this with list prepended in reverse.static <E> ConsPStack<E> singleton(E e) intsize()/ REQUIRED METHODS FROM AbstractSequentialList ////subList(int start) subList(int start, int end) / OVERRIDDEN METHODS FROM AbstractSequentialList ////Methods inherited from class AbstractUnmodifiableSequentialList
add, add, addAll, addAll, clear, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sortMethods inherited from class AbstractSequentialList
get, iteratorMethods inherited from class AbstractList
equals, hashCode, indexOf, lastIndexOf, listIterator, removeRangeMethods inherited from class AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
add, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
EMPTY
/ STATIC FACTORY METHODS //// -
first
/ PRIVATE CONSTRUCTORS //// -
rest
-
size
private final int size
-
-
Constructor Details
-
ConsPStack
private ConsPStack() -
ConsPStack
-
-
Method Details
-
empty
- Type Parameters:
E-- Returns:
- an empty stack
-
singleton
- Type Parameters:
E-- Parameters:
e-- Returns:
- empty().plus(e)
-
from
- Type Parameters:
E-- Parameters:
list-- Returns:
- a stack consisting of the elements of list in the order of list.iterator()
-
from
-
size
public int size()/ REQUIRED METHODS FROM AbstractSequentialList ////- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>- Specified by:
listIteratorin classAbstractSequentialList<E>
-
subList
-
plus
-
plusAll
Description copied from interface:PStackReturns a stack consisting of the elements of this with list prepended in reverse. -
plus
-
plusAll
-
minus
Description copied from interface:PSequenceReturns a sequence consisting of the elements of this without the first occurrence of e. -
minus
-
minusAll
-
with
-
subList
-