java.lang.Object
java.lang.Record
io.jenetics.util.IntRange
- Record Components:
min- the minimum value of the rangemax- the maximum value of the range
- All Implemented Interfaces:
Serializable
Integer range class.
- Since:
- 3.2
- Version:
- 8.3
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int value) Checks whether the givenvalueis within the range[min, max).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Return the intersection ofthisrange with theother.intmax()Returns the value of themaxrecord component.intmin()Returns the value of theminrecord component.static IntRangeof(int 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 IntRangeof(int min, int 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.intsize()Return the size of theIntRange:max - min.stream()toString()Returns a string representation of this record class.
-
Constructor Details
-
IntRange
Create a new range instance.- Parameters:
min- the minimum value of the rangemax- the maximum value of the range- Throws:
IllegalArgumentException- ifmin > max
-
IntRange
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 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
-
size
Return the size of theIntRange:max - min.- Returns:
- the size of the int range
- Since:
- 3.9
-
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
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. UseIntRange(int, int)instead.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
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. UseIntRange(int)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 theminrecord component.- Returns:
- the value of the
minrecord component
-
max
Returns the value of themaxrecord component.- Returns:
- the value of the
maxrecord component
-