Class MergedIntIterator

  • All Implemented Interfaces:
    LazyIntIterator

    public class MergedIntIterator
    extends java.lang.Object
    implements LazyIntIterator
    An iterator returning the union of the integers returned by two IntIterators. The two iterators must return integers in an increasing fashion; the resulting MergedIntIterator will do the same. Duplicates will be eliminated.
    • Constructor Summary

      Constructors 
      Constructor Description
      MergedIntIterator​(LazyIntIterator it0, LazyIntIterator it1)
      Creates a new merged iterator by merging two given iterators; the resulting iterator will not emit more than n integers.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int nextInt()
      The next integer returned by this iterator, or the special marker if this iterator is exhausted.
      int skip​(int s)
      Skips a given number of elements.
      • Methods inherited from class java.lang.Object

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

      • MergedIntIterator

        public MergedIntIterator​(LazyIntIterator it0,
                                 LazyIntIterator it1)
        Creates a new merged iterator by merging two given iterators; the resulting iterator will not emit more than n integers.
        Parameters:
        it0 - the first (monotonically nondecreasing) component iterator.
        it1 - the second (monotonically nondecreasing) component iterator.
    • Method Detail

      • nextInt

        public int nextInt()
        Description copied from interface: LazyIntIterator
        The next integer returned by this iterator, or the special marker if this iterator is exhausted.
        Specified by:
        nextInt in interface LazyIntIterator
        Returns:
        next integer returned by this iterator, or the special marker if this iterator is exhausted.
      • skip

        public int skip​(int s)
        Description copied from interface: LazyIntIterator
        Skips a given number of elements.
        Specified by:
        skip in interface LazyIntIterator
        Parameters:
        s - the number of elements to skip.
        Returns:
        the number of elements actually skipped (which might be less than n if this iterator is exhausted).