org.multiverse.collections

## Class NaiveTxnLinkedList<E>

- java.lang.Object
- - org.multiverse.collections.AbstractTxnCollection<E>
  - - org.multiverse.collections.NaiveTxnLinkedList<E>

Type Parameters:
  `E` -

All Implemented Interfaces:
  java.lang.Iterable<E>, java.util.Collection<E>, java.util.Deque<E>, java.util.Queue<E>, TxnCollection<E>, TxnDeque<E>, TxnIterable<E>, TxnList<E>, TxnQueue<E>

    public final class NaiveTxnLinkedList<E>
    extends AbstractTxnCollection<E>
    implements TxnDeque<E>, TxnList<E>

A LinkedList implementation that also acts as a TxnQueue, TxnDeque.

### Field Summary

### Fields inherited from class org.multiverse.collections.AbstractTxnCollection

`defaultRefFactory, stm`

### Constructor Summary

Constructors
Constructor and Description
`NaiveTxnLinkedList(Stm stm)`
`NaiveTxnLinkedList(Stm stm, int capacity)`

### Method Summary

Methods
`boolean` `add(Txn tx, E e)` Ensures that this collection contains the specified element (optional operation).
`void` `addFirst(E e)`
`void` `addFirst(Txn tx, E e)`
`void` `addLast(E e)`
`void` `addLast(Txn tx, E e)`
`void` `clear(Txn tx)` Removes all of the elements from this collection (optional operation).
`boolean` `contains(Txn tx, java.lang.Object o)` Returns `true` if this collection contains the specified element.
`TxnIterator<E>` `descendingIterator()`
`TxnIterator<E>` `descendingIterator(Txn tx)`
`E` `element()`
`E` `element(Txn tx)`
`E` `get(int index)`
`E` `get(Txn tx, int index)`
`int` `getCapacity()`
`E` `getFirst()`
`E` `getFirst(Txn tx)`
`E` `getLast()`
`E` `getLast(Txn tx)`
`int` `indexOf(java.lang.Object item)`
`int` `indexOf(Txn tx, java.lang.Object item)`
`TxnIterator<E>` `iterator(Txn tx)` Returns an iterator over a set of elements of type T.
`int` `lastIndexOf(java.lang.Object item)`
`int` `lastIndexOf(Txn tx, java.lang.Object item)`
`boolean` `offer(E item)`
`boolean` `offer(Txn tx, E item)`
`boolean` `offerFirst(E e)`
`boolean` `offerFirst(Txn tx, E item)`
`boolean` `offerLast(E e)`
`boolean` `offerLast(Txn tx, E item)`
`E` `peek()`
`E` `peek(Txn tx)`
`E` `peekFirst()`
`E` `peekFirst(Txn tx)`
`E` `peekLast()`
`E` `peekLast(Txn tx)`
`E` `poll()`
`E` `poll(Txn tx)`
`E` `pollFirst()`
`E` `pollFirst(Txn tx)`
`E` `pollLast()`
`E` `pollLast(Txn tx)`
`E` `pop()`
`E` `pop(Txn tx)`
`void` `push(E e)`
`void` `push(Txn tx, E e)`
`void` `put(E item)`
`void` `put(Txn tx, E item)`
`void` `putFirst(E item)`
`void` `putFirst(Txn tx, E item)`
`void` `putLast(E item)`
`void` `putLast(Txn tx, E item)`
`E` `remove()`
`E` `remove(int index)`
`E` `remove(Txn tx)`
`E` `remove(Txn tx, int index)`
`boolean` `remove(Txn tx, java.lang.Object o)` Removes a single instance of the specified element from this collection, if it is present (optional operation).
`E` `removeFirst()`
`E` `removeFirst(Txn tx)`
`boolean` `removeFirstOccurrence(java.lang.Object o)`
`boolean` `removeFirstOccurrence(Txn tx, java.lang.Object o)`
`E` `removeLast()`
`E` `removeLast(Txn tx)`
`boolean` `removeLastOccurrence(java.lang.Object o)`
`boolean` `removeLastOccurrence(Txn tx, java.lang.Object o)`
`E` `set(int index, E element)`
`E` `set(Txn tx, int index, E element)`
`int` `size(Txn tx)` Returns the number of elements in this collection.
`E` `take()`
`E` `take(Txn tx)`
`E` `takeFirst()`
`E` `takeFirst(Txn tx)`
`E` `takeLast()`
`E` `takeLast(Txn tx)`
`java.lang.String` `toString(Txn tx)`

### Methods inherited from class org.multiverse.collections.AbstractTxnCollection

`add, addAll, addAll, addAll, addAll, clear, contains, containsAll, containsAll, getStm, isEmpty, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString`

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

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

### Methods inherited from interface org.multiverse.api.collections.TxnCollection

`addAll, addAll, addAll, containsAll, getStm, isEmpty`

### Methods inherited from interface org.multiverse.api.collections.TxnIterable

`iterator`

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

`add, contains, iterator, remove, size`

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

`addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray`

### Constructor Detail

#### NaiveTxnLinkedList

    public NaiveTxnLinkedList(Stm stm)

#### NaiveTxnLinkedList

    public NaiveTxnLinkedList(Stm stm,
                      int capacity)

### Method Detail

#### getCapacity

    public int getCapacity()

Specified by:
  `getCapacity` in interface `TxnQueue<E>`

#### set

    public E set(int index,
        E element)

Specified by:
  `set` in interface `TxnList<E>`

#### set

    public E set(Txn tx,
        int index,
        E element)

Specified by:
  `set` in interface `TxnList<E>`

#### size

    public int size(Txn tx)

Description copied from interface: `TxnCollection`
Returns the number of elements in this collection. If this collection contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

Specified by:
  `size` in interface `TxnCollection<E>`
Parameters:
  `tx` - the transaction used for this operation.
Returns:
  the number of elements in this collection

#### indexOf

    public int indexOf(java.lang.Object item)

Specified by:
  `indexOf` in interface `TxnList<E>`

#### indexOf

    public int indexOf(Txn tx,
              java.lang.Object item)

Specified by:
  `indexOf` in interface `TxnList<E>`

#### lastIndexOf

    public int lastIndexOf(java.lang.Object item)

Specified by:
  `lastIndexOf` in interface `TxnList<E>`

#### lastIndexOf

    public int lastIndexOf(Txn tx,
                  java.lang.Object item)

Specified by:
  `lastIndexOf` in interface `TxnList<E>`

#### contains

    public boolean contains(Txn tx,
                   java.lang.Object o)

Description copied from interface: `TxnCollection`
Returns `true` if this collection contains the specified element. More formally, returns `true` if and only if this collection contains at least one element `e` such that `(o==null ? e==null : o.equals(e))`.

Specified by:
  `contains` in interface `TxnCollection<E>`
Parameters:
  `tx` - the transaction used for this operation.
  `o` - element whose presence in this collection is to be tested
Returns:
  `true` if this collection contains the specified element

#### remove

    public boolean remove(Txn tx,
                 java.lang.Object o)

Description copied from interface: `TxnCollection`
Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element `e` such that `(o==null ? e==null : o.equals(e))`, if this collection contains one or more such elements. Returns `true` if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Specified by:
  `remove` in interface `TxnCollection<E>`
Parameters:
  `tx` - the transaction used for this operation.
  `o` - element to be removed from this collection, if present
Returns:
  `true` if an element was removed as a result of this call

#### clear

    public void clear(Txn tx)

Description copied from interface: `TxnCollection`
Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Specified by:
  `clear` in interface `TxnCollection<E>`
Parameters:
  `tx` - the transaction used for this operation.

#### element

    public E element()

Specified by:
  `element` in interface `java.util.Deque<E>`
Specified by:
  `element` in interface `java.util.Queue<E>`

#### element

    public E element(Txn tx)

Specified by:
  `element` in interface `TxnQueue<E>`

#### pop

    public E pop()

Specified by:
  `pop` in interface `java.util.Deque<E>`

#### pop

    public E pop(Txn tx)

Specified by:
  `pop` in interface `TxnDeque<E>`

#### push

    public void push(E e)

Specified by:
  `push` in interface `java.util.Deque<E>`

#### push

    public void push(Txn tx,
            E e)

Specified by:
  `push` in interface `TxnDeque<E>`

#### remove

    public E remove(int index)

Specified by:
  `remove` in interface `TxnList<E>`

#### remove

    public E remove(Txn tx,
           int index)

Specified by:
  `remove` in interface `TxnList<E>`

#### removeFirst

    public E removeFirst()

Specified by:
  `removeFirst` in interface `java.util.Deque<E>`

#### removeFirst

    public E removeFirst(Txn tx)

Specified by:
  `removeFirst` in interface `TxnDeque<E>`

#### removeLast

    public E removeLast()

Specified by:
  `removeLast` in interface `java.util.Deque<E>`

#### removeLast

    public E removeLast(Txn tx)

Specified by:
  `removeLast` in interface `TxnDeque<E>`

#### remove

    public E remove()

Specified by:
  `remove` in interface `java.util.Deque<E>`
Specified by:
  `remove` in interface `java.util.Queue<E>`

#### remove

    public E remove(Txn tx)

Specified by:
  `remove` in interface `TxnQueue<E>`

#### removeFirstOccurrence

    public boolean removeFirstOccurrence(java.lang.Object o)

Specified by:
  `removeFirstOccurrence` in interface `java.util.Deque<E>`

#### removeFirstOccurrence

    public boolean removeFirstOccurrence(Txn tx,
                                java.lang.Object o)

Specified by:
  `removeFirstOccurrence` in interface `TxnDeque<E>`

#### removeLastOccurrence

    public boolean removeLastOccurrence(java.lang.Object o)

Specified by:
  `removeLastOccurrence` in interface `java.util.Deque<E>`

#### removeLastOccurrence

    public boolean removeLastOccurrence(Txn tx,
                               java.lang.Object o)

Specified by:
  `removeLastOccurrence` in interface `TxnDeque<E>`

#### getFirst

    public E getFirst()

Specified by:
  `getFirst` in interface `java.util.Deque<E>`

#### getFirst

    public E getFirst(Txn tx)

Specified by:
  `getFirst` in interface `TxnDeque<E>`

#### getLast

    public E getLast()

Specified by:
  `getLast` in interface `java.util.Deque<E>`

#### getLast

    public E getLast(Txn tx)

Specified by:
  `getLast` in interface `TxnDeque<E>`

#### get

    public E get(int index)

Specified by:
  `get` in interface `TxnList<E>`

#### get

    public E get(Txn tx,
        int index)

Specified by:
  `get` in interface `TxnList<E>`

#### addFirst

    public void addFirst(E e)

Specified by:
  `addFirst` in interface `java.util.Deque<E>`

#### addFirst

    public void addFirst(Txn tx,
                E e)

Specified by:
  `addFirst` in interface `TxnDeque<E>`

#### addLast

    public void addLast(E e)

Specified by:
  `addLast` in interface `java.util.Deque<E>`

#### addLast

    public void addLast(Txn tx,
               E e)

Specified by:
  `addLast` in interface `TxnDeque<E>`

#### add

    public boolean add(Txn tx,
              E e)

Description copied from interface: `TxnCollection`
Ensures that this collection contains the specified element (optional operation). Returns `true` if this collection changed as a result of the call. (Returns `false` if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add `null` elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning `false`). This preserves the invariant that a collection always contains the specified element after this call returns.

Specified by:
  `add` in interface `TxnCollection<E>`
Parameters:
  `tx` - the transaction used for this operation.
  `e` - element whose presence in this collection is to be ensured
Returns:
  `true` if this collection changed as a result of the call

#### putFirst

    public void putFirst(E item)

Specified by:
  `putFirst` in interface `TxnDeque<E>`

#### putFirst

    public void putFirst(Txn tx,
                E item)

Specified by:
  `putFirst` in interface `TxnDeque<E>`

#### put

    public void put(E item)

Specified by:
  `put` in interface `TxnQueue<E>`

#### put

    public void put(Txn tx,
           E item)

Specified by:
  `put` in interface `TxnQueue<E>`

#### putLast

    public void putLast(E item)

Specified by:
  `putLast` in interface `TxnDeque<E>`

#### putLast

    public void putLast(Txn tx,
               E item)

Specified by:
  `putLast` in interface `TxnDeque<E>`

#### take

    public E take()

Specified by:
  `take` in interface `TxnQueue<E>`

#### take

    public E take(Txn tx)

Specified by:
  `take` in interface `TxnQueue<E>`

#### takeFirst

    public E takeFirst()

Specified by:
  `takeFirst` in interface `TxnDeque<E>`

#### takeFirst

    public E takeFirst(Txn tx)

Specified by:
  `takeFirst` in interface `TxnDeque<E>`

#### takeLast

    public E takeLast()

Specified by:
  `takeLast` in interface `TxnDeque<E>`

#### takeLast

    public E takeLast(Txn tx)

Specified by:
  `takeLast` in interface `TxnDeque<E>`

#### offerFirst

    public boolean offerFirst(E e)

Specified by:
  `offerFirst` in interface `java.util.Deque<E>`

#### offerFirst

    public boolean offerFirst(Txn tx,
                     E item)

Specified by:
  `offerFirst` in interface `TxnDeque<E>`

#### offerLast

    public boolean offerLast(E e)

Specified by:
  `offerLast` in interface `java.util.Deque<E>`

#### offerLast

    public boolean offerLast(Txn tx,
                    E item)

Specified by:
  `offerLast` in interface `TxnDeque<E>`

#### offer

    public boolean offer(E item)

Specified by:
  `offer` in interface `java.util.Deque<E>`
Specified by:
  `offer` in interface `java.util.Queue<E>`

#### offer

    public boolean offer(Txn tx,
                E item)

Specified by:
  `offer` in interface `TxnQueue<E>`

#### pollFirst

    public E pollFirst()

Specified by:
  `pollFirst` in interface `java.util.Deque<E>`

#### pollFirst

    public E pollFirst(Txn tx)

Specified by:
  `pollFirst` in interface `TxnDeque<E>`

#### pollLast

    public E pollLast()

Specified by:
  `pollLast` in interface `java.util.Deque<E>`

#### pollLast

    public E pollLast(Txn tx)

Specified by:
  `pollLast` in interface `TxnDeque<E>`

#### poll

    public E poll()

Specified by:
  `poll` in interface `java.util.Deque<E>`
Specified by:
  `poll` in interface `java.util.Queue<E>`

#### poll

    public E poll(Txn tx)

Specified by:
  `poll` in interface `TxnQueue<E>`

#### peekFirst

    public E peekFirst()

Specified by:
  `peekFirst` in interface `java.util.Deque<E>`

#### peekFirst

    public E peekFirst(Txn tx)

Specified by:
  `peekFirst` in interface `TxnDeque<E>`

#### peekLast

    public E peekLast()

Specified by:
  `peekLast` in interface `java.util.Deque<E>`

#### peekLast

    public E peekLast(Txn tx)

Specified by:
  `peekLast` in interface `TxnDeque<E>`

#### peek

    public E peek()

Specified by:
  `peek` in interface `java.util.Deque<E>`
Specified by:
  `peek` in interface `java.util.Queue<E>`

#### peek

    public E peek(Txn tx)

Specified by:
  `peek` in interface `TxnQueue<E>`

#### iterator

    public TxnIterator<E> iterator(Txn tx)

Description copied from interface: `TxnIterable`
Returns an iterator over a set of elements of type T.

Specified by:
  `iterator` in interface `TxnIterable<E>`
Parameters:
  `tx` - the Txn used for this Operation.
Returns:
  an Iterator.

#### descendingIterator

    public TxnIterator<E> descendingIterator()

Specified by:
  `descendingIterator` in interface `java.util.Deque<E>`

#### descendingIterator

    public TxnIterator<E> descendingIterator(Txn tx)

Specified by:
  `descendingIterator` in interface `TxnDeque<E>`

#### toString

    public java.lang.String toString(Txn tx)

Specified by:
  `toString` in interface `TxnCollection<E>`