Class IteratorConcat<T>

  • All Implemented Interfaces:
    java.util.Iterator<T>

    public class IteratorConcat<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Iterator of Iterators IteratorConcat is better when there are lots of iterators to be joined. IteratorCons is slightly better for two iterators.
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorConcat()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.util.Iterator<T> iter)  
      static <T> java.util.Iterator<T> concat​(java.util.Iterator<T> iter1, java.util.Iterator<T> iter2)
      Usually, it is better to create an IteratorConcat explicitly and add iterator if there are going to be many.
      boolean hasNext()  
      T next()  
      • Methods inherited from class java.lang.Object

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

        forEachRemaining, remove
    • Constructor Detail

      • IteratorConcat

        public IteratorConcat()
    • Method Detail

      • concat

        public static <T> java.util.Iterator<T> concat​(java.util.Iterator<T> iter1,
                                                       java.util.Iterator<T> iter2)
        Usually, it is better to create an IteratorConcat explicitly and add iterator if there are going to be many.
        Parameters:
        iter1 -
        iter2 -
        Returns:
        Iterator
        See Also:
        IteratorCons
      • add

        public void add​(java.util.Iterator<T> iter)
      • hasNext

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

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