Package io.jenetics.util
Class IntRange
- java.lang.Object
-
- io.jenetics.util.IntRange
-
- All Implemented Interfaces:
Serializable
public final class IntRange extends Object implements Serializable
Integer range class.- Since:
- 3.2
- Version:
- 6.0
- Author:
- Franz Wilhelmstötter
- See Also:
- Serialized Form
- Implementation Note:
- This class is immutable and thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)inthashCode()intmax()Return the maximum value of the integer range.intmin()Return the minimum value of the integer range.static IntRangeof(int value)Return a new (half open) range, which contains only the given value:[value, value + 1).static IntRangeof(int min, int max)Create a newIntRangeobject with the givenminandmaxvalues.intsize()Return the size of theIntRange:max - min.IntStreamstream()StringtoString()
-
-
-
Method Detail
-
min
public int min()
Return the minimum value of the integer range.- Returns:
- the minimum value of the integer range
-
max
public int max()
Return the maximum value of the integer range.- Returns:
- the maximum value of the integer range
-
size
public int size()
Return the size of theIntRange:max - min.- Returns:
- the size of the int range
- Since:
- 3.9
-
stream
public IntStream stream()
Returns a sequential orderedIntStreamfrommin()(inclusive) tomax()(exclusive) by an incremental step of1.An equivalent sequence of increasing values can be produced sequentially using a
forloop as follows:for (int i = range.min(); i < range.max(); ++i) { ... }- Returns:
- a sequential
IntStreamfor the range ofintelements - Since:
- 3.4
-
of
public static IntRange of(int min, int max)
Create a newIntRangeobject with the givenminandmaxvalues.- Parameters:
min- the lower bound of the integer rangemax- the upper bound of the integer range- Returns:
- a new
IntRangeobject - Throws:
IllegalArgumentException- ifmin > max
-
of
public static IntRange of(int value)
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
-
-