Package org.multiverse.collections
Class NaiveTxnStack<E>
- java.lang.Object
-
- org.multiverse.collections.AbstractTxnCollection<E>
-
- org.multiverse.collections.NaiveTxnStack<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,TxnCollection<E>
,TxnIterable<E>
,TxnStack<E>
public final class NaiveTxnStack<E> extends AbstractTxnCollection<E> implements TxnStack<E>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
NaiveTxnStack.It<E>
(package private) static class
NaiveTxnStack.Node<E>
-
Field Summary
Fields Modifier and Type Field Description private int
capacity
private TxnRef<NaiveTxnStack.Node<E>>
head
private TxnInteger
size
-
Fields inherited from class org.multiverse.collections.AbstractTxnCollection
defaultRefFactory, stm
-
-
Constructor Summary
Constructors Constructor Description NaiveTxnStack(Stm stm)
NaiveTxnStack(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
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.int
getCapacity()
TxnIterator<E>
iterator(Txn tx)
Returns an iterator over a set of elements of type T.boolean
offer(E item)
boolean
offer(Txn tx, E item)
E
peek()
E
peek(Txn tx)
E
poll()
E
poll(Txn tx)
E
pop()
E
pop(Txn tx)
void
push(E item)
void
push(Txn tx, E item)
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).int
size(Txn tx)
Returns the number of elements in this collection.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
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, 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
-
-
-
-
Field Detail
-
capacity
private final int capacity
-
head
private final TxnRef<NaiveTxnStack.Node<E>> head
-
size
private final TxnInteger size
-
-
Method Detail
-
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
-
getCapacity
public int getCapacity()
- Specified by:
getCapacity
in interfaceTxnStack<E>
-
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.
-
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
-
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.
-
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
-
toString
public java.lang.String toString(Txn tx)
- Specified by:
toString
in interfaceTxnCollection<E>
-
-