Class Range

java.lang.Object
edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
edu.gvsu.kurmasz.warszawa.listgen.Range

public class Range
extends IntegerListGenerator
Generate lists of integers within a specified range (like a simple for loop).
Author:
Zachary Kurmas
  • Constructor Summary

    Constructors 
    Constructor Description
    Range()  
  • Method Summary

    Modifier and Type Method Description
    long[] generateLongArray​(long start, long stop, long step)
    Generate an array of long integers containing the values between start and stop (inclusive).

    Methods inherited from class edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator

    generateIntArray, generateIntList, generateLongList

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • generateLongArray

      public long[] generateLongArray​(long start, long stop, long step)
      Generate an array of long integers containing the values between start and stop (inclusive). Calling generateLongArray(start, stop, step) will produce the list of values taken on by i in this loop: for(int i = start; i <= stop; i+= step).

      The parameters must meet these conditions:

      • start <= stop
      • step >= 1
      • start and stop defined such that the total range (stop - start + 1) is a valid Java long. (This means that calling generateLongArray(Long.MIN_VALUE, 1, 1) won't work.)
      • start, stop, and step defined such that the number of values generated is a valid Java int (i.e., not larger than the maximum size of an array).
      Specified by:
      generateLongArray in class IntegerListGenerator
      Parameters:
      start - the first value in the output.
      stop - the upper-bound for values in the output. (If step is not equal to 1, then stop may not appear in the output. Must be >= start.
      step - the difference between successive values in the list. Must be >= 1.
      Returns:
      an array of long integers.
      Throws:
      java.lang.IllegalArgumentException - if the parameters violate any of the conditions listed above.