Range
, java.lang.Iterable<T>
, java.util.Collection<T>
, java.util.List<T>
public class ObjectRange extends java.util.AbstractList implements Range
IntRange
. If you make any changes to this
class, you might consider making parallel changes to IntRange
.Constructor | Description |
---|---|
ObjectRange(java.lang.Comparable from,
java.lang.Comparable to) |
Creates a new
ObjectRange . |
ObjectRange(java.lang.Comparable from,
java.lang.Comparable to,
boolean reverse) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
contains(java.lang.Object value) |
|
boolean |
containsWithinBounds(java.lang.Object value) |
Checks whether a value is between the from and to values of a Range
|
protected java.lang.Object |
decrement(java.lang.Object value) |
Decrements by one
|
boolean |
equals(ObjectRange that) |
Compares an
ObjectRange to another ObjectRange . |
boolean |
equals(java.lang.Object that) |
|
java.lang.Object |
get(int index) |
|
java.lang.Comparable |
getFrom() |
The lower value in the range.
|
java.lang.Comparable |
getTo() |
The upper value in the range.
|
protected java.lang.Object |
increment(java.lang.Object value) |
Increments by one
|
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.Iterator |
iterator() |
|
int |
size() |
|
java.util.List |
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.
|
java.util.List |
subList(int fromIndex,
int toIndex) |
|
java.lang.String |
toString() |
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
add, add, addAll, clear, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set
add, add, addAll, addAll, clear, containsAll, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, toArray, toArray
public ObjectRange(java.lang.Comparable from, java.lang.Comparable to)
from
- the first value in the range.to
- the last value in the range.public ObjectRange(java.lang.Comparable from, java.lang.Comparable to, boolean reverse)
public boolean equals(java.lang.Object that)
public boolean equals(ObjectRange that)
ObjectRange
to another ObjectRange
.that
- the object to check equality withtrue
if the ranges are equalpublic java.lang.Comparable getFrom()
public java.lang.Comparable getTo()
public boolean isReverse()
public java.lang.Object get(int index)
get
in interface java.util.List<T extends java.lang.Comparable>
get
in class java.util.AbstractList
public java.util.Iterator iterator()
iterator
in interface java.util.Collection<T extends java.lang.Comparable>
iterator
in interface java.lang.Iterable<T extends java.lang.Comparable>
iterator
in interface java.util.List<T extends java.lang.Comparable>
iterator
in class java.util.AbstractList
public boolean containsWithinBounds(java.lang.Object value)
containsWithinBounds
in interface Range
value
- the value of interestpublic int size()
public java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List<T extends java.lang.Comparable>
subList
in class java.util.AbstractList
public java.lang.String toString()
toString
in class java.util.AbstractCollection
public java.lang.String inspect()
public boolean contains(java.lang.Object value)
public void step(int step, Closure closure)
public java.util.List step(int step)
protected java.lang.Object increment(java.lang.Object value)
value
- the value to incrementprotected java.lang.Object decrement(java.lang.Object value)
value
- the value to decrement