Class SmallSortedMap.DescendingEntryIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.util.Map.Entry<K,​V>>
    Enclosing class:
    SmallSortedMap<K extends java.lang.Comparable<K>,​V>

    private class SmallSortedMap.DescendingEntryIterator
    extends java.lang.Object
    implements java.util.Iterator<java.util.Map.Entry<K,​V>>
    Reverse Iterator implementation that switches from the entry array to the overflow entries appropriately.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<java.util.Map.Entry<K,​V>> lazyOverflowIterator  
      private int pos  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.Iterator<java.util.Map.Entry<K,​V>> getOverflowIterator()
      It is important to create the overflow iterator only after the array entries have been iterated over because the overflow entry set changes when the client calls remove() on the array entries, which invalidates any existing iterators.
      boolean hasNext()  
      java.util.Map.Entry<K,​V> 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
    • Field Detail

      • pos

        private int pos
      • lazyOverflowIterator

        private java.util.Iterator<java.util.Map.Entry<K extends java.lang.Comparable<K>,​V>> lazyOverflowIterator
    • Constructor Detail

      • DescendingEntryIterator

        private DescendingEntryIterator()
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.util.Map.Entry<K extends java.lang.Comparable<K>,​V>>
      • next

        public java.util.Map.Entry<K,​V> next()
        Specified by:
        next in interface java.util.Iterator<java.util.Map.Entry<K extends java.lang.Comparable<K>,​V>>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<java.util.Map.Entry<K extends java.lang.Comparable<K>,​V>>
      • getOverflowIterator

        private java.util.Iterator<java.util.Map.Entry<K,​V>> getOverflowIterator()
        It is important to create the overflow iterator only after the array entries have been iterated over because the overflow entry set changes when the client calls remove() on the array entries, which invalidates any existing iterators.