public final class IntRange extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
getMax()
Return the maximum value of the integer range.
|
int |
getMin()
Return the minimum value of the integer range.
|
int |
hashCode() |
static IntRange |
of(int value)
Return a new (half open) range, which contains only the given value:
[value, value + 1) . |
static IntRange |
of(int min,
int max)
Create a new
IntRange object with the given min and
max values. |
int |
size()
Return the size of the
IntRange : max - min . |
IntStream |
stream()
|
String |
toString() |
public int getMin()
public int getMax()
public int size()
IntRange
: max - min
.public IntStream stream()
IntStream
from getMin()
(inclusive) to getMax()
(exclusive) by an incremental step of
1
.
An equivalent sequence of increasing values can be produced sequentially
using a for
loop as follows:
for (int i = range.getMin(); i < range.getMax(); ++i) {
...
}
IntStream
for the range of int
elementspublic static IntRange of(int min, int max)
IntRange
object with the given min
and
max
values.min
- the lower bound of the integer rangemax
- the upper bound of the integer rangeIntRange
objectIllegalArgumentException
- if min > max
public static IntRange of(int value)
[value, value + 1)
.value
- the value of the created (half open) integer range© 2007-2018 Franz Wilhelmstötter (2018-02-14 08:27)