Class IteratorTransform<I,​T>

  • Type Parameters:
    I - Input iterator type
    T - Output iterator type
    All Implemented Interfaces:
    java.util.Iterator<T>
    Direct Known Subclasses:
    AbstractRegionBSPTree.RegionBoundaryIterator

    public abstract class IteratorTransform<I,​T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Class that wraps another iterator, converting each input iterator value into one or more output iterator values.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<I> inputIterator
      Input iterator instance that supplies the input values for this instance.
      private java.util.Deque<T> outputQueue
      Output value queue.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected IteratorTransform​(java.util.Iterator<I> inputIterator)
      Create a new instance that uses the given iterator as the input source.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void acceptInput​(I input)
      Accept a value from the input iterator.
      protected void addAllOutput​(java.util.Collection<T> values)
      Add multiple values to the output queue.
      protected void addOutput​(T value)
      Add a value to the output queue.
      boolean hasNext()
      private boolean loadNextOutput()
      Load the next output values into the output queue.
      T next()
      • 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, remove
    • Field Detail

      • inputIterator

        private final java.util.Iterator<I> inputIterator
        Input iterator instance that supplies the input values for this instance.
      • outputQueue

        private final java.util.Deque<T> outputQueue
        Output value queue.
    • Constructor Detail

      • IteratorTransform

        protected IteratorTransform​(java.util.Iterator<I> inputIterator)
        Create a new instance that uses the given iterator as the input source.
        Parameters:
        inputIterator - iterator supplying input values
    • Method Detail

      • hasNext

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

        public T next()
        Specified by:
        next in interface java.util.Iterator<I>
      • loadNextOutput

        private boolean loadNextOutput()
        Load the next output values into the output queue. Returns true if the output queue contains more entries.
        Returns:
        true if more output values are available
      • addOutput

        protected void addOutput​(T value)
        Add a value to the output queue.
        Parameters:
        value - value to add to the output queue
      • addAllOutput

        protected void addAllOutput​(java.util.Collection<T> values)
        Add multiple values to the output queue.
        Parameters:
        values - values to add to the output queue
      • acceptInput

        protected abstract void acceptInput​(I input)
        Accept a value from the input iterator. This method should take the input value and add one or more values to the output queue.
        Parameters:
        input - value from the input iterator