public class Range
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
lower
The range's lower bound, inclusive.
|
int |
upper
The range's upper bound, inclusive.
|
Constructor and Description |
---|
Range()
Constructs an empty range with lower and upper both zero.
|
Range(int lower,
int upper)
Constructs a range with a specified lower bound and upper bound.
|
Range(Range range)
Constructs a range with the lower bound and upper bound of a specified range.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isEmpty()
Indicates whether or not this range is empty.
|
int |
length()
Returns the length of the interval between this range's lower bound and upper bound, or 0 if this range is empty.
|
Range |
set(int lower,
int upper)
Sets this range to the specified lower bound and upper bound.
|
Range |
set(Range range)
Sets this range to the lower bound and upper bound of a specified range.
|
Range |
setEmpty()
Sets this range to an empty range.
|
public int lower
public int upper
public Range()
public Range(int lower, int upper)
lower
- the lower bound, inclusiveupper
- the upper bound, inclusivepublic Range(Range range)
range
- the range specifying the valuesjava.lang.IllegalArgumentException
- If the range is nullpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int length()
public Range set(int lower, int upper)
lower
- the new lower bound, inclusiveupper
- the new upper bound, inclusivepublic Range set(Range range)
range
- the range specifying the new valuesjava.lang.IllegalArgumentException
- If the range is nullpublic Range setEmpty()
public boolean isEmpty()