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>

public class ConcurrentLinkedBag<T> extends Object implements 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.
  • Constructor Details

    • ConcurrentLinkedBag

      public ConcurrentLinkedBag()
  • Method Details

    • add

      public void add(T e)
      Add an element to the bag.
      Parameters:
      e - the element
    • getHead

      public ConcurrentLinkedBag<T>.Node 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

      public Iterator<T> iterator()
      Returns an iterator over elements of type T. The iterator is not thread-safe.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      an iterator
    • emptyBag

      public static final <T> ConcurrentLinkedBag<T> emptyBag()