Class VisitOnceFIFOWorkingSet<E>

  • Type Parameters:
    E - the type of the elements that this working set contains
    All Implemented Interfaces:
    VisitOnceWorkingSet<E>, WorkingSet<E>

    public class VisitOnceFIFOWorkingSet<E>
    extends java.lang.Object
    implements VisitOnceWorkingSet<E>
    A FIFO working set that guarantees that each element will be added to this working set no more than once. It works by pushing elements only if they were not already added before (even if they have already been popped out). This implementation is not thread-safe.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.util.Collection<E> getContents()
      Yields the elements currently in this working set.
      java.util.Collection<E> getSeen()
      Yields the elements visited (and thus no longer able to be added to this working set) by this object.
      int hashCode()  
      boolean isEmpty()
      Yields true if and only if this working set is empty.
      static <E> VisitOnceFIFOWorkingSet<E> mk()
      Yields a new, empty working set.
      E peek()
      Returns the next element to be processed from this working set without removing it.
      E pop()
      Removes the next element to be processed from this working set and returns it.
      void push​(E e)
      Pushes a new element into this working set.
      int size()
      Yields the size of this working set, that is, the number of elements contained in it.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • mk

        public static <E> VisitOnceFIFOWorkingSet<E> mk()
        Yields a new, empty working set.
        Type Parameters:
        E - the type of the elements that the returned working set contains
        Returns:
        the new working set
      • push

        public void push​(E e)
        Description copied from interface: WorkingSet
        Pushes a new element into this working set.
        Specified by:
        push in interface WorkingSet<E>
        Parameters:
        e - the element
      • pop

        public E pop()
        Description copied from interface: WorkingSet
        Removes the next element to be processed from this working set and returns it.
        Specified by:
        pop in interface WorkingSet<E>
        Returns:
        the next element to process
      • peek

        public E peek()
        Description copied from interface: WorkingSet
        Returns the next element to be processed from this working set without removing it.
        Specified by:
        peek in interface WorkingSet<E>
        Returns:
        the next element to process
      • size

        public int size()
        Description copied from interface: WorkingSet
        Yields the size of this working set, that is, the number of elements contained in it.
        Specified by:
        size in interface WorkingSet<E>
        Returns:
        the size
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: WorkingSet
        Yields true if and only if this working set is empty.
        Specified by:
        isEmpty in interface WorkingSet<E>
        Returns:
        true if that condition holds
      • getContents

        public java.util.Collection<E> getContents()
        Description copied from interface: WorkingSet
        Yields the elements currently in this working set.
        Specified by:
        getContents in interface WorkingSet<E>
        Returns:
        the elements
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSeen

        public java.util.Collection<E> getSeen()
        Description copied from interface: VisitOnceWorkingSet
        Yields the elements visited (and thus no longer able to be added to this working set) by this object.
        Specified by:
        getSeen in interface VisitOnceWorkingSet<E>
        Returns:
        the collection of visited elements
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object