Package 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:
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 Summary
-
Fields inherited from class org.multiverse.collections.AbstractTxnCollection
defaultRefFactory, stm
-
-
Constructor Summary
Constructors Constructor Description NaiveTxnLinkedList(Stm stm)NaiveTxnLinkedList(Stm stm, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Txn tx, E e)Ensures that this collection contains the specified element (optional operation).voidaddFirst(E e)voidaddFirst(Txn tx, E e)voidaddLast(E e)voidaddLast(Txn tx, E e)voidclear(Txn tx)Removes all of the elements from this collection (optional operation).booleancontains(Txn tx, Object o)Returns true if this collection contains the specified element.TxnIterator<E>descendingIterator()TxnIterator<E>descendingIterator(Txn tx)Eelement()Eelement(Txn tx)Eget(int index)Eget(Txn tx, int index)intgetCapacity()EgetFirst()EgetFirst(Txn tx)EgetLast()EgetLast(Txn tx)intindexOf(Object item)intindexOf(Txn tx, Object item)TxnIterator<E>iterator(Txn tx)Returns an iterator over a set of elements of type T.intlastIndexOf(Object item)intlastIndexOf(Txn tx, Object item)booleanoffer(E item)booleanoffer(Txn tx, E item)booleanofferFirst(E e)booleanofferFirst(Txn tx, E item)booleanofferLast(E e)booleanofferLast(Txn tx, E item)Epeek()Epeek(Txn tx)EpeekFirst()EpeekFirst(Txn tx)EpeekLast()EpeekLast(Txn tx)Epoll()Epoll(Txn tx)EpollFirst()EpollFirst(Txn tx)EpollLast()EpollLast(Txn tx)Epop()Epop(Txn tx)voidpush(E e)voidpush(Txn tx, E e)voidput(E item)voidput(Txn tx, E item)voidputFirst(E item)voidputFirst(Txn tx, E item)voidputLast(E item)voidputLast(Txn tx, E item)Eremove()Eremove(int index)Eremove(Txn tx)Eremove(Txn tx, int index)booleanremove(Txn tx, Object o)Removes a single instance of the specified element from this collection, if it is present (optional operation).EremoveFirst()EremoveFirst(Txn tx)booleanremoveFirstOccurrence(Object o)booleanremoveFirstOccurrence(Txn tx, Object o)EremoveLast()EremoveLast(Txn tx)booleanremoveLastOccurrence(Object o)booleanremoveLastOccurrence(Txn tx, Object o)Eset(int index, E element)Eset(Txn tx, int index, E element)intsize(Txn tx)Returns the number of elements in this collection.Etake()Etake(Txn tx)EtakeFirst()EtakeFirst(Txn tx)EtakeLast()EtakeLast(Txn tx)StringtoString(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 java.util.Collection
clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
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
-
-
-
-
Method Detail
-
getCapacity
public int getCapacity()
- Specified by:
getCapacityin interfaceTxnQueue<E>
-
size
public int size(Txn tx)
Description copied from interface:TxnCollectionReturns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Specified by:
sizein interfaceTxnCollection<E>- Parameters:
tx- the transaction used for this operation.- Returns:
- the number of elements in this collection
-
lastIndexOf
public int lastIndexOf(Object item)
- Specified by:
lastIndexOfin interfaceTxnList<E>
-
lastIndexOf
public int lastIndexOf(Txn tx, Object item)
- Specified by:
lastIndexOfin interfaceTxnList<E>
-
contains
public boolean contains(Txn tx, Object o)
Description copied from interface:TxnCollectionReturns 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:
containsin interfaceTxnCollection<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:TxnCollectionRemoves 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:
removein interfaceTxnCollection<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:TxnCollectionRemoves all of the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
clearin interfaceTxnCollection<E>- Parameters:
tx- the transaction used for this operation.
-
element
public E element()
-
removeFirst
public E removeFirst()
- Specified by:
removeFirstin interfaceDeque<E>
-
removeFirst
public E removeFirst(Txn tx)
- Specified by:
removeFirstin interfaceTxnDeque<E>
-
removeLast
public E removeLast()
- Specified by:
removeLastin interfaceDeque<E>
-
removeLast
public E removeLast(Txn tx)
- Specified by:
removeLastin interfaceTxnDeque<E>
-
remove
public E remove()
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)
- Specified by:
removeFirstOccurrencein interfaceDeque<E>
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Txn tx, Object o)
- Specified by:
removeFirstOccurrencein interfaceTxnDeque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(Object o)
- Specified by:
removeLastOccurrencein interfaceDeque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(Txn tx, Object o)
- Specified by:
removeLastOccurrencein interfaceTxnDeque<E>
-
add
public boolean add(Txn tx, E e)
Description copied from interface:TxnCollectionEnsures 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:
addin interfaceTxnCollection<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
-
offerFirst
public boolean offerFirst(E e)
- Specified by:
offerFirstin interfaceDeque<E>
-
offerFirst
public boolean offerFirst(Txn tx, E item)
- Specified by:
offerFirstin interfaceTxnDeque<E>
-
offer
public boolean offer(E item)
-
poll
public E poll()
-
peek
public E peek()
-
iterator
public TxnIterator<E> iterator(Txn tx)
Description copied from interface:TxnIterableReturns an iterator over a set of elements of type T.- Specified by:
iteratorin interfaceTxnIterable<E>- Parameters:
tx- the Txn used for this Operation.- Returns:
- an Iterator.
-
descendingIterator
public TxnIterator<E> descendingIterator()
- Specified by:
descendingIteratorin interfaceDeque<E>
-
descendingIterator
public TxnIterator<E> descendingIterator(Txn tx)
- Specified by:
descendingIteratorin interfaceTxnDeque<E>
-
toString
public String toString(Txn tx)
- Specified by:
toStringin interfaceTxnCollection<E>
-
-