Class RandomLongIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.Long>, java.util.PrimitiveIterator<java.lang.Long,​java.util.function.LongConsumer>, java.util.PrimitiveIterator.OfLong

    public final class RandomLongIterator
    extends java.lang.Object
    implements java.util.PrimitiveIterator.OfLong
    iterates over a range of long values in random order using a https://en.wikipedia.org/wiki/Linear_congruential_generator without having to have all the numbers in memory. The iterator can be reset, but not re-sized. The iteration order does not change after resetting.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.PrimitiveIterator

        java.util.PrimitiveIterator.OfDouble, java.util.PrimitiveIterator.OfInt, java.util.PrimitiveIterator.OfLong
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      long nextLong()  
      void reset()
      Reset the iterator to the beginning of this iteration.
      • 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

        remove
      • Methods inherited from interface java.util.PrimitiveIterator.OfLong

        forEachRemaining, forEachRemaining, next
    • Constructor Detail

      • RandomLongIterator

        public RandomLongIterator​(long start,
                                  long end)
        Parameters:
        start - iteration start, inclusive
        end - iteration end, exclusive
      • RandomLongIterator

        public RandomLongIterator​(long end,
                                  java.util.Random random)
        Parameters:
        end - iteration end, exclusive
        random - random instance to provide the initial seed
      • RandomLongIterator

        public RandomLongIterator​(long start,
                                  long end,
                                  java.util.Random random)
        Parameters:
        start - iteration start, inclusive
        end - iteration end, exclusive
        random - random instance to provide the initial seed
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.Long>
      • nextLong

        public long nextLong()
        Specified by:
        nextLong in interface java.util.PrimitiveIterator.OfLong
      • reset

        public void reset()
        Reset the iterator to the beginning of this iteration.