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 betweenstartandstop(inclusive).Methods inherited from class edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
generateIntArray, generateIntList, generateLongList
-
Constructor Details
-
Range
public Range()
-
-
Method Details
-
generateLongArray
public long[] generateLongArray(long start, long stop, long step)Generate an array of long integers containing the values betweenstartandstop(inclusive). CallinggenerateLongArray(start, stop, step)will produce the list of values taken on byiin this loop:for(int i = start; i <= stop; i+= step).The parameters must meet these conditions:
-
start <= stop -
step >= 1 -
startandstopdefined such that the total range (stop - start + 1) is a valid Javalong. (This means that callinggenerateLongArray(Long.MIN_VALUE, 1, 1)won't work.) -
start,stop, andstepdefined such that the number of values generated is a valid Javaint(i.e., not larger than the maximum size of an array).
- Specified by:
generateLongArrayin classIntegerListGenerator- Parameters:
start- the first value in the output.stop- the upper-bound for values in the output. (Ifstepis not equal to 1, thenstopmay 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.
-
-