public interface Range<T extends java.lang.Comparable>
extends java.util.List<T>
from
value and calling next()
successively
until you reach the to
value. For a reverse range,
the list is obtained by starting at the to
value and
successively calling previous()
until the from
value is reached.Modifier and Type | Method and Description |
---|---|
boolean |
containsWithinBounds(java.lang.Object o)
Indicates whether an object is greater than or equal to the
from
value for the range and less than or equal to the to value. |
T |
getFrom()
The lower value in the range.
|
T |
getTo()
The upper value in the range.
|
java.lang.String |
inspect() |
boolean |
isReverse()
Indicates whether this is a reverse range which iterates backwards
starting from the to value and ending on the from value
|
java.util.List<T> |
step(int step)
Forms a list by stepping through the range by the indicated interval.
|
void |
step(int step,
Closure closure)
Steps through the range, calling a closure for each number.
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
T getFrom()
T getTo()
boolean isReverse()
true
if this is a reverse rangeboolean containsWithinBounds(java.lang.Object o)
from
value for the range and less than or equal to the to
value.
This may be true even for values not contained in the range.
Example: from = 1.5 , to = 3, next() increments by 1 containsWithinBounds(2) == true contains(2) == false
o
- the object to check against the boundaries of the rangetrue
if the object is between the from and to valuesvoid step(int step, Closure closure)
step
- the amount by which to step. If negative, steps through the
range backwards.closure
- the Closure
to calljava.util.List<T> step(int step)
step
- the amount by which to step. If negative, steps through the
range backwards.