Class NaiveTxnLinkedList<E>

java.lang.Object
org.multiverse.collections.AbstractTxnCollection<E>
org.multiverse.collections.NaiveTxnLinkedList<E>
Type Parameters:
E -
All Implemented Interfaces:
Iterable<E>, Collection<E>, Deque<E>, 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 Details

  • Constructor Details

    • NaiveTxnLinkedList

      public NaiveTxnLinkedList(Stm stm)
    • NaiveTxnLinkedList

      public NaiveTxnLinkedList(Stm stm, int capacity)
  • Method Details

    • 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(Object item)
      Specified by:
      indexOf in interface TxnList<E>
    • indexOf

      public int indexOf(Txn tx, Object item)
      Specified by:
      indexOf in interface TxnList<E>
    • lastIndexOf

      public int lastIndexOf(Object item)
      Specified by:
      lastIndexOf in interface TxnList<E>
    • lastIndexOf

      public int lastIndexOf(Txn tx, Object item)
      Specified by:
      lastIndexOf in interface TxnList<E>
    • entry

      private NaiveTxnLinkedList.Entry<E> entry(Txn tx, int index)
    • contains

      public boolean contains(Txn tx, 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, 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 Deque<E>
      Specified by:
      element in interface Queue<E>
    • element

      public E element(Txn tx)
      Specified by:
      element in interface TxnQueue<E>
    • pop

      public E pop()
      Specified by:
      pop in interface 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 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 Deque<E>
    • removeFirst

      public E removeFirst(Txn tx)
      Specified by:
      removeFirst in interface TxnDeque<E>
    • removeLast

      public E removeLast()
      Specified by:
      removeLast in interface Deque<E>
    • removeLast

      public E removeLast(Txn tx)
      Specified by:
      removeLast in interface TxnDeque<E>
    • remove

      public E remove()
      Specified by:
      remove in interface Deque<E>
      Specified by:
      remove in interface Queue<E>
    • remove

      public E remove(Txn tx)
      Specified by:
      remove in interface TxnQueue<E>
    • removeFirstOccurrence

      public boolean removeFirstOccurrence(Object o)
      Specified by:
      removeFirstOccurrence in interface Deque<E>
    • removeFirstOccurrence

      public boolean removeFirstOccurrence(Txn tx, Object o)
      Specified by:
      removeFirstOccurrence in interface TxnDeque<E>
    • removeLastOccurrence

      public boolean removeLastOccurrence(Object o)
      Specified by:
      removeLastOccurrence in interface Deque<E>
    • removeLastOccurrence

      public boolean removeLastOccurrence(Txn tx, Object o)
      Specified by:
      removeLastOccurrence in interface TxnDeque<E>
    • getFirst

      public E getFirst()
      Specified by:
      getFirst in interface Deque<E>
    • getFirst

      public E getFirst(Txn tx)
      Specified by:
      getFirst in interface TxnDeque<E>
    • getLast

      public E getLast()
      Specified by:
      getLast in interface 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 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 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 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 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 Deque<E>
      Specified by:
      offer in interface 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 Deque<E>
    • pollFirst

      public E pollFirst(Txn tx)
      Specified by:
      pollFirst in interface TxnDeque<E>
    • pollLast

      public E pollLast()
      Specified by:
      pollLast in interface Deque<E>
    • pollLast

      public E pollLast(Txn tx)
      Specified by:
      pollLast in interface TxnDeque<E>
    • poll

      public E poll()
      Specified by:
      poll in interface Deque<E>
      Specified by:
      poll in interface Queue<E>
    • poll

      public E poll(Txn tx)
      Specified by:
      poll in interface TxnQueue<E>
    • peekFirst

      public E peekFirst()
      Specified by:
      peekFirst in interface Deque<E>
    • peekFirst

      public E peekFirst(Txn tx)
      Specified by:
      peekFirst in interface TxnDeque<E>
    • peekLast

      public E peekLast()
      Specified by:
      peekLast in interface Deque<E>
    • peekLast

      public E peekLast(Txn tx)
      Specified by:
      peekLast in interface TxnDeque<E>
    • peek

      public E peek()
      Specified by:
      peek in interface Deque<E>
      Specified by:
      peek in interface 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 Deque<E>
    • descendingIterator

      public TxnIterator<E> descendingIterator(Txn tx)
      Specified by:
      descendingIterator in interface TxnDeque<E>
    • toString

      public String toString(Txn tx)
      Specified by:
      toString in interface TxnCollection<E>