Package io.jenetics.util
Class LongRange
- java.lang.Object
-
- io.jenetics.util.LongRange
-
- All Implemented Interfaces:
Serializable
public final class LongRange extends Object implements Serializable
Long range class.- Since:
- 3.2
- Version:
- 6.0
- 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 boolean
equals(Object obj)
int
hashCode()
long
max()
Return the maximum value of the long range.long
min()
Return the minimum value of the long range.static LongRange
of(long value)
Return a new (half open) range, which contains only the given value:[value, value + 1)
.static LongRange
of(long min, long max)
Create a newLongRange
object with the givenmin
andmax
values.LongStream
stream()
String
toString()
-
-
-
Method Detail
-
min
public long min()
Return the minimum value of the long range.- Returns:
- the minimum value of the long range
-
max
public long max()
Return the maximum value of the long range.- Returns:
- the maximum value of the long range
-
stream
public LongStream stream()
Returns a sequential orderedLongStream
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 (long i = range.min(); i < range.max(); ++i) { ... }
- Returns:
- a sequential
LongStream
for the range oflong
elements - Since:
- 3.4
-
of
public static LongRange of(long min, long max)
Create a newLongRange
object with the givenmin
andmax
values.- Parameters:
min
- the lower bound of the long rangemax
- the upper bound of the long range- Returns:
- a new
LongRange
object - Throws:
IllegalArgumentException
- ifmin > max
-
of
public static LongRange of(long 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
-
-