public class Range
extends java.lang.Object
RangeBuilder, serves
as the public API for the Range Fun(ctions) library, and is intended to be used in
most cases where ranges are created.| Modifier and Type | Method and Description |
|---|---|
static RangeBuilder |
of(int start)
Returns a new
RangeBuilder with a 'from' value of start, and a default step of 1. |
static java.lang.Iterable<java.lang.Integer> |
of(int start,
int end)
Returns a new
Iterable<Integer> set to provide a range for the
given start and end values, with a default step value of 1. |
static java.lang.Iterable<java.lang.Integer> |
of(int start,
int end,
int step)
Returns a new
Iterable<Integer> set to provide a range for the
given values. |
static RangeBuilder |
of(java.lang.Object array)
Returns a new
RangeBuilder set to build a range over the length of the array. |
static java.lang.Iterable<java.lang.Integer> |
range(int start)
Returns a new
RangeBuilder with a 'from' value of start, and a default step of 1. |
static java.lang.Iterable<java.lang.Integer> |
range(int start,
int end)
Returns a new
Iterable<Integer> set to provide a range for the
given start and end values, with a default step value of 1. |
static java.lang.Iterable<java.lang.Integer> |
range(int start,
int end,
int step)
Returns a new
Iterable<Integer> set to provide a range for the
given values. |
static RangeBuilder |
range(java.lang.Object array)
Returns a new
RangeBuilder set to build a range over the length of the array. |
static RangeBuilder |
to(int end)
Returns a new
RangeBuilder with a 'to' value of end, a default 'from' value of 1, and a default step of 1. |
public static java.lang.Iterable<java.lang.Integer> of(int start,
int end,
int step)
Iterable<Integer> set to provide a range for the
given values.
Note that if intending to get a descending range (where start is greater than end), the
value of step need not be negative.start - The beginning of the range, the first Integer to be returned by the
Iterable's Iterator.end - The end of the range. This value may or may not be returned by the
Iterable's Iterator (depending on the chosen step value),
but it is guaranteed to never go beyond this value.step - The value by which the value returned by the Iterable's Iterator
will change upon each successive call to next().Iterable<Integer> set to provide a range for the
given values.public static java.lang.Iterable<java.lang.Integer> of(int start,
int end)
Iterable<Integer> set to provide a range for the
given start and end values, with a default step value of 1.start - The beginning of the range, the first Integer to be returned by the
Iterable's Iterator.end - The end of the range. Since a default step value of one is used, this value is
guaranteed to be returned by the Iterable's Iterator.Iterable<Integer> set to provide a range for the
given values.of(int, int, int)public static RangeBuilder of(int start)
RangeBuilder with a 'from' value of start, and a default step of 1.
This method is intended to serve as a natural entry point into the 'fluent' API provided by
RangeBuilder.start - The supposed beginning of the range, passed to RangeBuilder. Can be
overwritten at a later time through the RangeBuilder object.RangeBuilder with a 'from' value of start and a default step of 1.RangeBuilderpublic static RangeBuilder of(java.lang.Object array)
RangeBuilder set to build a range over the length of the array.array - The array from which to derive bounds for the returned RangeBuilder. Note that this
object MUST be an array, or an IllegalArgumentException will be thrown.RangeBuilder set to build a range over the length of the array.java.lang.IllegalArgumentException - if the passed argument is not an array.Range.of(0).to(array.length - 1).step(1)
and is intended to serve as a convenience method. Also, it returns a RangeBuilder
to facilitate easy backwards iteration of the array.public static RangeBuilder to(int end)
RangeBuilder with a 'to' value of end, a default 'from' value of 1, and a default step of 1.
This method is intended to serve as a natural entry point into the 'fluent' API provided by
RangeBuilder.end - The supposed end of the range, passed to RangeBuilder. Can be
overwritten at a later time through the RangeBuilder object.RangeBuilder with a 'to' value of end, a default 'from' value of 1, and a default step of 1.RangeBuilderpublic static java.lang.Iterable<java.lang.Integer> range(int start,
int end,
int step)
Iterable<Integer> set to provide a range for the
given values.
Note that if intending to get a descending range (where start is greater than end), the
value of step need not be negative.start - The beginning of the range, the first Integer to be returned by the
Iterable's Iterator.end - The end of the range. This value may or may not be returned by the
Iterable's Iterator (depending on the chosen step value),
but it is guaranteed to never go beyond this value.step - The value by which the value returned by the Iterable's Iterator
will change upon each successive call to next().Iterable<Integer> set to provide a range for the
given values.of(int, int, int)Range.of(start, end, step) and us
intended to serve as a convenience method to preserve readability when Range
is statically imported.public static java.lang.Iterable<java.lang.Integer> range(int start,
int end)
Iterable<Integer> set to provide a range for the
given start and end values, with a default step value of 1.start - The beginning of the range, the first Integer to be returned by the
Iterable's Iterator.end - The end of the range. Since a default step value of one is used, this value
is guaranteed to be returned by the Iterable's Iterator.Iterable<Integer> set to provide a range for the
given values.of(int, int, int),
of(int, int)Range.of(start, end) and us
intended to serve as a convenience method to preserve readability when Range
is statically imported.public static java.lang.Iterable<java.lang.Integer> range(int start)
RangeBuilder with a 'from' value of start, and a default step of 1.
This method is intended to serve as a natural entry point into the 'fluent' API provided by
RangeBuilder.start - The supposed beginning of the range, passed to RangeBuilder. Can be
overwritten at a later time through the RangeBuilder object.RangeBuilder with a 'from' value of start and a default step of 1.RangeBuilder,
of(int)Range.of(start) and us
intended to serve as a convenience method to preserve readability when Range
is statically imported.public static RangeBuilder range(java.lang.Object array)
RangeBuilder set to build a range over the length of the array.array - The array from which to derive bounds for the returned RangeBuilder. Note that this
object MUST be an array, or an IllegalArgumentException will be thrown.RangeBuilder set to build a range over the length of the array.java.lang.IllegalArgumentException - if the passed argument is not an array.Range.of(0).to(array.length - 1).step(1)
and is intended to serve as a convenience method. Also, it returns a RangeBuilder
to facilitate easy backwards iteration of the array., This method also behaves exactly as if calling Range.of(array) and us
intended to serve as a convenience method to preserve readability when Range
is statically imported.