public class Progressions
extends java.lang.Object
Progression outside of this library. '
Note that all of the methods contained in this class are intended to be statically imported
before use, for enhanced readability. For instance, for (int i : range(1, 5)) is
far better to read than for (int i : Progressions.range(1, 5)), and should thus be
preferred.| Modifier and Type | Method and Description |
|---|---|
static Progression |
count(int to)
Creates a new
Progression instance that behaves like a range of integers, from 0 to the given
ending value, exclusive. |
static Progression |
progression(int start,
int end,
int step)
Creates a new
Progression instance with the given starting, ending, and stepping
values. |
static Progression |
range(int start,
int end)
Creates a new
Progression instance that behaves like a range of integers, with the given
starting and ending values. |
static Progression |
range(java.lang.Object array)
Creates a new
Progression instance that behaves like a range of all valid indices
of the given array. |
public static Progression progression(int start, int end, int step)
Progression instance with the given starting, ending, and stepping
values.start - the first integer in the progression, inclusiveend - the point which no integer in the progression will go over, but may or may not be equal tostep - the amount by which each integer in the progression will differ from the previous onepublic static Progression range(int start, int end)
Progression instance that behaves like a range of integers, with the given
starting and ending values.start - the first integer in the progression, inclusiveend - the last integer in the progression, inclusiveprogression(int, int, int)Progressions.progression(start, end, 1).public static Progression count(int to)
Progression instance that behaves like a range of integers, from 0 to the given
ending value, exclusive. This method is intended to be used when looping a certain number of times.to - the last integer in the progression, exclusiverange(int, int)Progressions.range(0, to - 1).public static Progression range(java.lang.Object array)
Progression instance that behaves like a range of all valid indices
of the given array.array - the array for which to generate indicesjava.lang.NullPointerException - if the given object is nulljava.lang.IllegalArgumentException - if the given object is not an arraycount(int)Progressions.count(array.length)
when passed valid arguments.