public interface Range<T> extends java.util.Collection<T>, HeadTail<T>
A range represent a set of values between to bounds, optionally with a step (or increment) from one value to the next.
Modifier and Type | Method and Description |
---|---|
Range<T> |
decrementBy(int value)
Sets the negative increment of the range.
|
boolean |
encloses(T value)
Checks if the range encloses the value.
|
T |
from()
Gets the lower bound of the range.
|
int |
increment()
Gets the increment of the range.
|
Range<T> |
incrementBy(int value)
Sets the increment of the range.
|
Range<T> |
reversed()
Creates a new reversed range from this range.
|
T |
to()
Gets the upper bound of the range.
|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
head, isEmpty, tail, toIterable
T from()
T to()
int increment()
Range<T> incrementBy(int value)
value
- the new increment.Range<T> decrementBy(int value)
this is equivalent to:
range.incrementBy(-value)
value
- the new increment.boolean encloses(T value)
i.e. if from() <= value
and value < to()
(for positive increments, resp. for
negative ones), regardless the increment value.
For instance a range between 0 and 5 with an increment of 2 encloses 1 but don't contains it.
value
- the value to check.