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:
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 Description NaiveTxnLinkedList(Stm stm)
NaiveTxnLinkedList(Stm stm, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 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:
getCapacity
in interfaceTxnQueue<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 interfaceTxnCollection<E>
- Parameters:
tx
- the transaction used for this operation.- Returns:
- the number of elements in this collection
-
indexOf
public int indexOf(Txn tx, java.lang.Object item)
-
lastIndexOf
public int lastIndexOf(java.lang.Object item)
- Specified by:
lastIndexOf
in interfaceTxnList<E>
-
lastIndexOf
public int lastIndexOf(Txn tx, java.lang.Object item)
- Specified by:
lastIndexOf
in interfaceTxnList<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 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, 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 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:TxnCollection
Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
clear
in interfaceTxnCollection<E>
- Parameters:
tx
- the transaction used for this operation.
-
element
public E element()
-
removeFirst
public E removeFirst(Txn tx)
- Specified by:
removeFirst
in interfaceTxnDeque<E>
-
removeLast
public E removeLast(Txn tx)
- Specified by:
removeLast
in interfaceTxnDeque<E>
-
remove
public E remove()
-
removeFirstOccurrence
public boolean removeFirstOccurrence(java.lang.Object o)
- Specified by:
removeFirstOccurrence
in interfacejava.util.Deque<E>
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Txn tx, java.lang.Object o)
- Specified by:
removeFirstOccurrence
in interfaceTxnDeque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(java.lang.Object o)
- Specified by:
removeLastOccurrence
in interfacejava.util.Deque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(Txn tx, java.lang.Object o)
- Specified by:
removeLastOccurrence
in interfaceTxnDeque<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.)- Specified by:
add
in 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(Txn tx, E item)
- Specified by:
offerFirst
in 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:TxnIterable
Returns an iterator over a set of elements of type T.- Specified by:
iterator
in interfaceTxnIterable<E>
- Parameters:
tx
- the Txn used for this Operation.- Returns:
- an Iterator.
-
descendingIterator
public TxnIterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.Deque<E>
-
descendingIterator
public TxnIterator<E> descendingIterator(Txn tx)
- Specified by:
descendingIterator
in interfaceTxnDeque<E>
-
toString
public java.lang.String toString(Txn tx)
- Specified by:
toString
in interfaceTxnCollection<E>
-
-