java.lang.Object
io.jenetics.util.LongRange
- All Implemented Interfaces:
Serializable
Long range class.
- Since:
- 3.2
- Version:
- 6.0
- See Also:
- Implementation Note:
- This class is immutable and thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(long value) Checks whether the givenvalueis within the range[min, max).booleaninthashCode()Return the intersection ofthisrange with theother.longmax()Return the maximum value of the long range.longmin()Return the minimum value of the long range.static LongRangeof(long value) Return a new (half-open) range, which contains only the given value:[value, value + 1).static LongRangeof(long min, long max) Create a newLongRangeobject with the givenminandmaxvalues.stream()toString()
-
Method Details
-
min
Return the minimum value of the long range.- Returns:
- the minimum value of the long range
-
max
Return the maximum value of the long range.- Returns:
- the maximum value of the long range
-
contains
Checks whether the givenvalueis within the range[min, max).- Parameters:
value- the value to check- Returns:
trueif thevalueis with the range[min, max),falseotherwise- Since:
- 8.0
-
intersect
Return the intersection ofthisrange with theother.- Parameters:
other- the intersection range orOptional.empty()if there is none- Returns:
- the range intersection
- Since:
- 8.0
-
stream
Returns a sequential orderedLongStreamfrommin()(inclusive) tomax()(exclusive) by an incremental step of1.An equivalent sequence of increasing values can be produced sequentially using a
forloop as follows:for (long i = range.min(); i < range.max(); ++i) { // ... }- Returns:
- a sequential
LongStreamfor the range oflongelements - Since:
- 3.4
-
of
Create a newLongRangeobject with the givenminandmaxvalues.- Parameters:
min- the lower bound of the long rangemax- the upper bound of the long range- Returns:
- a new
LongRangeobject - 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
-