Class IntStepIterator

  • All Implemented Interfaces:
    IntIterator

    public class IntStepIterator
    extends java.lang.Object
    implements IntIterator
    An iterator over a sequence of integers with regular steps, e.g. 2, 4, 6, 8...
    • Constructor Summary

      Constructors 
      Constructor Description
      IntStepIterator​(int start, int step, int limit)
      Create an iterator over a sequence with regular steps
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Test whether there are any more integers in the sequence
      int next()
      Return the next integer in the sequence.
      • Methods inherited from class java.lang.Object

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

      • IntStepIterator

        public IntStepIterator​(int start,
                               int step,
                               int limit)
        Create an iterator over a sequence with regular steps
        Parameters:
        start - the first value to be returned
        step - the difference between successive values (must be non-zero)
        limit - if step>0, the iteration will not deliver any values greater than this limit; if step<0 the iteration will not deliver any values lower than this limit
    • Method Detail

      • hasNext

        public boolean hasNext()
        Description copied from interface: IntIterator
        Test whether there are any more integers in the sequence
        Specified by:
        hasNext in interface IntIterator
        Returns:
        true if there are more integers to come
      • next

        public int next()
        Description copied from interface: IntIterator
        Return the next integer in the sequence. The result is undefined unless hasNext() has been called and has returned true.
        Specified by:
        next in interface IntIterator
        Returns:
        the next integer in the sequence