public class Range
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static PrimitiveIntIterable |
indexes(java.util.Collection<?> list)
Return the range of indexes for accessing the given list.
|
static PrimitiveIntIterable |
indexes(int length)
Return indexes for accessing an array
or
java.util.List . |
static PrimitiveIntIterable |
indexes(java.lang.Object[] array)
Return the range of indexes for accessing the given array.
|
static PrimitiveIntIterable |
indexes(Sizeable s)
Return the range of indexes for accessing a sizeable object using standard indexing.
|
static PrimitiveIntIterable |
of(int start,
int end)
Get a range of integer numbers.
|
static PrimitiveIntIterable |
of(int start,
int end,
int step)
Get a range of integer numbers.
|
static PrimitiveLongIterable |
of(long start,
long end)
Get a range of long integer numbers.
|
static PrimitiveLongIterable |
of(long start,
long end,
long step)
Get a range of long integer numbers.
|
@NotNull public static PrimitiveIntIterable of(int start, int end, int step)
start
, adding step
on each iteration
until either end
is reached or the following step
would reach beyond end
(depending on step).
So of(1, 4, 1)
would return 1, 2, 3, 4)
, and
of(1, 4, 2
} would return 1, 3
.
start
- start value of range (included)end
- end value of range (possibly included depending on
step
). Has to be the same or larger
if step
is positive, and same or smaller
of step
is negativestep
- step size, must not be 0
java.lang.IllegalArgumentException
- if step
is 0
or start
, end
and step
do not match@NotNull public static PrimitiveIntIterable of(int start, int end)
start
, and a step width of either 1
(if end >= start) or {@code -1}
(if {@code end < start}
.start
- start value of range (included)end
- end value of range (included)@NotNull public static PrimitiveLongIterable of(long start, long end, long step)
start
, adding step
on each iteration
until either end
is reached or the following step
would reach beyond end
(depending on step).
So of(1L, 4L, 1L)
would return 1L, 2L, 3L, 4L)
, and
of(1L, 4L, 2L
} would return 1L, 3L
.
start
- start value of range (included)end
- end value of range (possibly included depending on
step
). Has to be the same or larger
if step
is positive, and same or smaller
of step
is negativestep
- step size, must not be 0
java.lang.IllegalArgumentException
- if step
is 0
or start
, end
and step
do not match@NotNull public static PrimitiveLongIterable of(long start, long end)
start
, and a step width of either 1L
(if end >= start) or {@code -1L}
(if {@code end < start}
.start
- start value of range (included)end
- end value of range (included)@NotNull public static PrimitiveIntIterable indexes(int length)
java.util.List
.length
- length/size of the array/listjava.lang.IllegalArgumentException
- if length
is negativefor an alternative
@NotNull public static PrimitiveIntIterable indexes(@NotNull java.lang.Object[] array)
array
- array@NotNull public static PrimitiveIntIterable indexes(@NotNull java.util.Collection<?> list)
list
- list@NotNull public static PrimitiveIntIterable indexes(@NotNull Sizeable s)
s
- sizeable object