Class ConcurrentLinkedBag<T>
java.lang.Object
edu.harvard.seas.pl.abcdatalog.util.datastructures.ConcurrentLinkedBag<T>
- Type Parameters:
T
- the type of the element of the bag
- All Implemented Interfaces:
Iterable<T>
A linked-list-backed bag that supports a minimal number of operations. Operations are
thread-safe, although iterators over the bag are not thread-safe.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an element to the bag.static final <T> ConcurrentLinkedBag
<T> emptyBag()
getHead()
Returns the head of the linked-list that backs this bag, or null if there is no head.iterator()
Returns an iterator over elements of type T.size()
Returns the number of elements that have been added to the set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ConcurrentLinkedBag
public ConcurrentLinkedBag()
-
-
Method Details
-
add
Add an element to the bag.- Parameters:
e
- the element
-
size
Returns the number of elements that have been added to the set.- Returns:
- the size of the set
-
getHead
Returns the head of the linked-list that backs this bag, or null if there is no head.- Returns:
- the head, or null
-
iterator
Returns an iterator over elements of type T. The iterator is not thread-safe. -
emptyBag
-