org.pcollections

## Class ConsPStack<E>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - java.util.AbstractSequentialList<E>
      - - org.pcollections.ConsPStack<E>

Type Parameters:
  `E` -

All Implemented Interfaces:
  Iterable<E>, Collection<E>, List<E>, PCollection<E>, PSequence<E>, PStack<E>

    public final class ConsPStack<E>
    extends AbstractSequentialList<E>
    implements PStack<E>

A simple persistent stack of non-null values.

This implementation is thread-safe (assuming Java's AbstractSequentialList is thread-safe), although its iterators may not be.

### Field Summary

### Fields inherited from class java.util.AbstractList

`modCount`

### Method Summary

Methods
`static <E> ConsPStack<E>` `empty()`
`static <E> ConsPStack<E>` `from(Collection<? extends E> list)`
`ListIterator<E>` `listIterator(int index)`
`ConsPStack<E>` `minus(int i)`
`ConsPStack<E>` `minus(Object e)` Returns a sequence consisting of the elements of this without the first occurrence of e.
`ConsPStack<E>` `minusAll(Collection<?> list)`
`ConsPStack<E>` `plus(E e)` Returns a stack consisting of the elements of this with e prepended.
`ConsPStack<E>` `plus(int i, E e)`
`ConsPStack<E>` `plusAll(Collection<? extends E> list)` Returns a stack consisting of the elements of this with list prepended in reverse.
`ConsPStack<E>` `plusAll(int i, Collection<? extends E> list)`
`static <E> ConsPStack<E>` `singleton(E e)`
`int` `size()`
`ConsPStack<E>` `subList(int start)`
`ConsPStack<E>` `subList(int start, int end)`
`ConsPStack<E>` `with(int i, E e)`

### Methods inherited from class java.util.AbstractSequentialList

`add, addAll, get, iterator, remove, set`

### Methods inherited from class java.util.AbstractList

`add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange`

### Methods inherited from class java.util.AbstractCollection

`addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.pcollections.PSequence

`add, addAll, remove, set`

### Methods inherited from interface org.pcollections.PCollection

`add, addAll, clear, remove, removeAll, retainAll`

### Methods inherited from interface java.util.List

`add, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, removeAll, retainAll, toArray, toArray`

### Method Detail

#### empty

    public static <E> ConsPStack<E> empty()

Type Parameters:
  `E` -
Returns:
  an empty stack

#### singleton

    public static <E> ConsPStack<E> singleton(E e)

Type Parameters:
  `E` -
Parameters:
  `e` -
Returns:
  empty().plus(e)

#### from

    public static <E> ConsPStack<E> from(Collection<? extends E> list)

Type Parameters:
  `E` -
Parameters:
  `list` -
Returns:
  a stack consisting of the elements of list in the order of list.iterator()

#### size

    public int size()

Specified by:
  `size` in interface `Collection<E>`
Specified by:
  `size` in interface `List<E>`
Specified by:
  `size` in class `AbstractCollection<E>`

#### listIterator

    public ListIterator<E> listIterator(int index)

Specified by:
  `listIterator` in interface `List<E>`
Specified by:
  `listIterator` in class `AbstractSequentialList<E>`

#### subList

    public ConsPStack<E> subList(int start,
                        int end)

Specified by:
  `subList` in interface `List<E>`
Specified by:
  `subList` in interface `PSequence<E>`
Specified by:
  `subList` in interface `PStack<E>`
Overrides:
  `subList` in class `AbstractList<E>`

#### plus

    public ConsPStack<E> plus(E e)

Description copied from interface: `PStack`
Returns a stack consisting of the elements of this with e prepended.

Specified by:
  `plus` in interface `PCollection<E>`
Specified by:
  `plus` in interface `PSequence<E>`
Specified by:
  `plus` in interface `PStack<E>`
Parameters:
  `e` - non-null
Returns:
  a collection which contains e and all of the elements of this

#### plusAll

    public ConsPStack<E> plusAll(Collection<? extends E> list)

Description copied from interface: `PStack`
Returns a stack consisting of the elements of this with list prepended in reverse.

Specified by:
  `plusAll` in interface `PCollection<E>`
Specified by:
  `plusAll` in interface `PSequence<E>`
Specified by:
  `plusAll` in interface `PStack<E>`
Parameters:
  `list` - contains no null elements
Returns:
  a collection which contains all of the elements of list and this

#### plus

    public ConsPStack<E> plus(int i,
                     E e)

Specified by:
  `plus` in interface `PSequence<E>`
Specified by:
  `plus` in interface `PStack<E>`
  `e` - non-null
Returns:
  a sequence consisting of the elements of this with e inserted at index i.

#### plusAll

    public ConsPStack<E> plusAll(int i,
                        Collection<? extends E> list)

Specified by:
  `plusAll` in interface `PSequence<E>`
Specified by:
  `plusAll` in interface `PStack<E>`
Returns:
  a sequence consisting of the elements of this with list inserted at index i.

#### minus

    public ConsPStack<E> minus(Object e)

Description copied from interface: `PSequence`
Returns a sequence consisting of the elements of this without the first occurrence of e.

Specified by:
  `minus` in interface `PCollection<E>`
Specified by:
  `minus` in interface `PSequence<E>`
Specified by:
  `minus` in interface `PStack<E>`
Returns:
  this with a single instance of e removed, if e is in this

#### minus

    public ConsPStack<E> minus(int i)

Specified by:
  `minus` in interface `PSequence<E>`
Specified by:
  `minus` in interface `PStack<E>`
Returns:
  a sequence consisting of the elements of this with the element at index i removed.

#### minusAll

    public ConsPStack<E> minusAll(Collection<?> list)

Specified by:
  `minusAll` in interface `PCollection<E>`
Specified by:
  `minusAll` in interface `PSequence<E>`
Specified by:
  `minusAll` in interface `PStack<E>`
Returns:
  this with all elements of list completely removed

#### with

    public ConsPStack<E> with(int i,
                     E e)

Specified by:
  `with` in interface `PSequence<E>`
Specified by:
  `with` in interface `PStack<E>`
Returns:
  a sequence consisting of the elements of this with e replacing the element at index i.

#### subList

    public ConsPStack<E> subList(int start)

Specified by:
  `subList` in interface `PStack<E>`
Returns:
  subList(start, this.size())

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015