Class FairBlockingQueue.FairIterator

  • All Implemented Interfaces:
    java.util.Iterator<E>
    Enclosing class:
    FairBlockingQueue<E>

    protected class FairBlockingQueue.FairIterator
    extends java.lang.Object
    implements java.util.Iterator<E>
    Iterator safe from concurrent modification exceptions. The iterator walks a snapshot of the queue contents taken when it was created, but remove() removes the last returned element - or, for element types with value semantics, an element equal to it - from the live queue. An element that was taken out of the queue and offered back as the same object between the snapshot and the removal is therefore also removed from the live queue - like the weakly consistent iterators of the JDK, this iterator makes no promise about seeing the current state of the queue.
    • Constructor Summary

      Constructors 
      Constructor Description
      FairIterator()
      Creates a new FairIterator with a snapshot of the current queue contents.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      E next()  
      void remove()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • FairIterator

        public FairIterator()
        Creates a new FairIterator with a snapshot of the current queue contents.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<E>
      • next

        public E next()
        Specified by:
        next in interface java.util.Iterator<E>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<E>