Class UpdatableIterator<E>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void forEachRemaining​(java.util.function.Consumer<? super E> action)  
      boolean hasNext()  
      E next()  
      void remove()  
      void repeat()
      If the current value should repeat.
      void reset()
      When reset is called, then if a new iterator has been provided by another thread via update method, then we switch over to using the new iterator.
      void update​(ResettableIterator<E> iterator)
      This can be called by another thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • update

        public void update​(ResettableIterator<E> iterator)
        This can be called by another thread. It sets a new iterator, that will be picked up on the next reset.
        Parameters:
        iterator - the new iterator to update to.
      • reset

        public void reset()
        When reset is called, then if a new iterator has been provided by another thread via update method, then we switch over to using the new iterator. It is important that on nulling off the changedIterator, we atomically compare and set as the changedIterator could be further updated by another thread whilst we are resetting, the subsequent update simply would be picked up on the next reset.
        Specified by:
        reset in interface ResettableIterator<E>
      • 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>
      • forEachRemaining

        public void forEachRemaining​(java.util.function.Consumer<? super E> action)
        Specified by:
        forEachRemaining in interface java.util.Iterator<E>