java.lang.Object
io.jenetics.util.IntRange
- All Implemented Interfaces:
Serializable
Integer range class.
- Since:
- 3.2
- Version:
- 6.0
- See Also:
- Implementation Note:
- This class is immutable and thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
int
max()
Return the maximum value of the integer range.int
min()
Return the minimum value of the integer range.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 newIntRange
object with the givenmin
andmax
values.int
size()
Return the size of theIntRange
:max - min
.stream()
toString()
-
Method Details
-
min
Return the minimum value of the integer range.- Returns:
- the minimum value of the integer range
-
max
Return the maximum value of the integer range.- Returns:
- the maximum value of the integer range
-
size
Return the size of theIntRange
:max - min
.- Returns:
- the size of the int range
- Since:
- 3.9
-
stream
Returns a sequential orderedIntStream
frommin()
(inclusive) tomax()
(exclusive) by an incremental step of1
.An equivalent sequence of increasing values can be produced sequentially using a
for
loop as follows:for (int i = range.min(); i < range.max(); ++i) { ... }
- Returns:
- a sequential
IntStream
for the range ofint
elements - Since:
- 3.4
-
of
Create a newIntRange
object with the givenmin
andmax
values.- Parameters:
min
- the lower bound of the integer rangemax
- the upper bound of the integer range- Returns:
- a new
IntRange
object - Throws:
IllegalArgumentException
- ifmin > max
-
of
Return a new (half-open) range, which contains only the given value:[value, value + 1)
.- Parameters:
value
- the value of the created (half-open) integer range- Returns:
- a new (half-open) range, which contains only the given value
- Since:
- 4.0
-
hashCode
-
equals
-
toString
-