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>
,SequencedCollection<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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final TxnRef
<NaiveTxnLinkedList.Entry<E>> private final TxnInteger
private final TxnRef
<NaiveTxnLinkedList.Entry<E>> Fields inherited from class org.multiverse.collections.AbstractTxnCollection
defaultRefFactory, stm
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Ensures that this collection contains the specified element (optional operation).void
void
void
void
void
Removes all of the elements from this collection (optional operation).boolean
Returns true if this collection contains the specified element.element()
private NaiveTxnLinkedList.Entry
<E> get
(int index) int
getFirst()
getLast()
int
int
Returns an iterator over a set of elements of type T.int
lastIndexOf
(Object item) int
lastIndexOf
(Txn tx, Object item) boolean
boolean
boolean
offerFirst
(E e) boolean
offerFirst
(Txn tx, E item) boolean
boolean
peek()
peekLast()
poll()
pollLast()
pop()
void
void
void
void
void
void
void
void
remove()
remove
(int index) boolean
Removes a single instance of the specified element from this collection, if it is present (optional operation).removeFirst
(Txn tx) boolean
boolean
removeFirstOccurrence
(Txn tx, Object o) removeLast
(Txn tx) boolean
boolean
removeLastOccurrence
(Txn tx, Object o) int
Returns the number of elements in this collection.take()
takeLast()
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 java.util.Deque
add, addAll, contains, iterator, remove, reversed, size
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
-
Field Details
-
capacity
private final int capacity -
size
-
head
-
tail
-
-
Constructor Details
-
NaiveTxnLinkedList
-
NaiveTxnLinkedList
-
-
Method Details
-
getCapacity
public int getCapacity()- Specified by:
getCapacity
in interfaceTxnQueue<E>
-
set
-
set
-
size
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
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceTxnList<E>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceTxnList<E>
-
entry
-
contains
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
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
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
-
element
-
pop
-
pop
-
push
-
push
-
remove
-
remove
-
removeFirst
- Specified by:
removeFirst
in interfaceDeque<E>
- Specified by:
removeFirst
in interfaceSequencedCollection<E>
-
removeFirst
- Specified by:
removeFirst
in interfaceTxnDeque<E>
-
removeLast
- Specified by:
removeLast
in interfaceDeque<E>
- Specified by:
removeLast
in interfaceSequencedCollection<E>
-
removeLast
- Specified by:
removeLast
in interfaceTxnDeque<E>
-
remove
-
remove
-
removeFirstOccurrence
- Specified by:
removeFirstOccurrence
in interfaceDeque<E>
-
removeFirstOccurrence
- Specified by:
removeFirstOccurrence
in interfaceTxnDeque<E>
-
removeLastOccurrence
- Specified by:
removeLastOccurrence
in interfaceDeque<E>
-
removeLastOccurrence
- Specified by:
removeLastOccurrence
in interfaceTxnDeque<E>
-
getFirst
-
getFirst
-
getLast
-
getLast
-
get
-
get
-
addFirst
-
addFirst
-
addLast
-
addLast
-
add
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
-
putFirst
-
putFirst
-
put
-
put
-
putLast
-
putLast
-
take
-
take
-
takeFirst
-
takeFirst
-
takeLast
-
takeLast
-
offerFirst
- Specified by:
offerFirst
in interfaceDeque<E>
-
offerFirst
- Specified by:
offerFirst
in interfaceTxnDeque<E>
-
offerLast
-
offerLast
-
offer
-
offer
-
pollFirst
-
pollFirst
-
pollLast
-
pollLast
-
poll
-
poll
-
peekFirst
-
peekFirst
-
peekLast
-
peekLast
-
peek
-
peek
-
iterator
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
- Specified by:
descendingIterator
in interfaceDeque<E>
-
descendingIterator
- Specified by:
descendingIterator
in interfaceTxnDeque<E>
-
toString
- Specified by:
toString
in interfaceTxnCollection<E>
-