java.lang.Object
java.lang.Record
io.jenetics.util.LongRange
- Record Components:
min
- the minimum value of the rangemax
- the maximum value of the range
- All Implemented Interfaces:
Serializable
Long range class.
- Since:
- 3.2
- Version:
- 8.3
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(long value) Checks whether the givenvalue
is within the range[min, max)
.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Return the intersection ofthis
range with theother
.long
max()
Returns the value of themax
record component.long
min()
Returns the value of themin
record component.static LongRange
of
(long value) Deprecated, for removal: This API element is subject to removal in a future version.Class is a record now, and this factory method will be removed in the next major version.static LongRange
of
(long min, long max) Deprecated, for removal: This API element is subject to removal in a future version.Class is a record now, and this factory method will be removed in the next major version.stream()
toString()
Returns a string representation of this record class.
-
Constructor Details
-
LongRange
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- Throws:
IllegalArgumentException
- ifmin > max
-
LongRange
Create 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
-
-
Method Details
-
contains
Checks whether the givenvalue
is within the range[min, max)
.- Parameters:
value
- the value to check- Returns:
true
if thevalue
is with the range[min, max)
,false
otherwise- Since:
- 8.0
-
intersect
Return the intersection ofthis
range with theother
.- Parameters:
other
- the intersection range orOptional.empty()
if there is none- Returns:
- the range intersection
- Since:
- 8.0
-
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
Deprecated, for removal: This API element is subject to removal in a future version.Class is a record now, and this factory method will be removed in the next major version. UseLongRange(long, long)
instead.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
Deprecated, for removal: This API element is subject to removal in a future version.Class is a record now, and this factory method will be removed in the next major version. UseLongRange(long)
instead.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
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
min
Returns the value of themin
record component.- Returns:
- the value of the
min
record component
-
max
Returns the value of themax
record component.- Returns:
- the value of the
max
record component
-