Package org.multiverse.collections
Class NaiveTxnHashSet<E>
- java.lang.Object
-
- org.multiverse.collections.AbstractTxnCollection<E>
-
- org.multiverse.collections.NaiveTxnHashSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>,TxnCollection<E>,TxnIterable<E>,TxnSet<E>
public final class NaiveTxnHashSet<E> extends AbstractTxnCollection<E> implements TxnSet<E>
-
-
Field Summary
-
Fields inherited from class org.multiverse.collections.AbstractTxnCollection
defaultRefFactory, stm
-
-
Constructor Summary
Constructors Constructor Description NaiveTxnHashSet(Stm stm)
-
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).voidclear(Txn tx)Removes all of the elements from this collection (optional operation).booleancontains(Object item)booleancontains(Txn tx, Object o)Returns true if this collection contains the specified element.TxnIterator<E>iterator(Txn tx)Returns an iterator over a set of elements of type T.booleanremove(Object item)booleanremove(Txn tx, Object item)Removes a single instance of the specified element from this collection, if it is present (optional operation).intsize(Txn tx)Returns the number of elements in this collection.StringtoString(Txn tx)-
Methods inherited from class org.multiverse.collections.AbstractTxnCollection
add, addAll, addAll, addAll, addAll, clear, containsAll, containsAll, getStm, isEmpty, isEmpty, iterator, 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
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
add, addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, spliterator, 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
-
-
-
-
Constructor Detail
-
NaiveTxnHashSet
public NaiveTxnHashSet(Stm stm)
-
-
Method Detail
-
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
-
contains
public boolean contains(Object item)
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractTxnCollection<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(Object item)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractTxnCollection<E>
-
remove
public boolean remove(Txn tx, Object item)
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.item- element to be removed from this collection, if present- Returns:
- true if an element was removed as a result of this call
-
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
-
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.
-
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.
-
toString
public String toString(Txn tx)
- Specified by:
toStringin interfaceTxnCollection<E>
-
-