Class MinMaxPriorityQueue.QueueIterator

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

    private class MinMaxPriorityQueue.QueueIterator
    extends java.lang.Object
    implements java.util.Iterator<E>
    Iterates the elements of the queue in no particular order.

    If the underlying queue is modified during iteration an exception will be thrown.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private QueueIterator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkModCount()  
      private boolean foundAndRemovedExactReference​(java.lang.Iterable<E> elements, E target)
      Returns true if an exact reference (==) was found and removed from the supplied iterable.
      boolean hasNext()  
      E next()  
      private void nextNotInSkipMe​(int c)
      Advances nextCursor to the index of the first element after c that is not in skipMe and returns size() if there is no such element.
      void remove()  
      private boolean removeExact​(java.lang.Object target)
      Removes only this exact instance, not others that are equals()
      • 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
    • Field Detail

      • cursor

        private int cursor
      • nextCursor

        private int nextCursor
      • expectedModCount

        private int expectedModCount
      • forgetMeNot

        @CheckForNull
        private java.util.Queue<E> forgetMeNot
      • skipMe

        @CheckForNull
        private java.util.List<E> skipMe
      • lastFromForgetMeNot

        @CheckForNull
        private E lastFromForgetMeNot
      • canRemove

        private boolean canRemove
    • Constructor Detail

      • QueueIterator

        private QueueIterator()
    • 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>
      • foundAndRemovedExactReference

        private boolean foundAndRemovedExactReference​(java.lang.Iterable<E> elements,
                                                      E target)
        Returns true if an exact reference (==) was found and removed from the supplied iterable.
      • removeExact

        private boolean removeExact​(java.lang.Object target)
        Removes only this exact instance, not others that are equals()
      • checkModCount

        private void checkModCount()
      • nextNotInSkipMe

        private void nextNotInSkipMe​(int c)
        Advances nextCursor to the index of the first element after c that is not in skipMe and returns size() if there is no such element.