public class ObjectRange extends AbstractList implements Range
modCount
Constructor and Description |
---|
ObjectRange(Comparable from,
Comparable to)
Creates a new
ObjectRange . |
ObjectRange(Comparable from,
Comparable to,
boolean reverse) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Object value)
iterates over all values and returns true if one value matches.
|
boolean |
containsWithinBounds(Object value)
Checks whether a value is between the from and to values of a Range
|
protected Object |
decrement(Object value)
Decrements by one
|
boolean |
equals(Object that) |
boolean |
equals(ObjectRange that)
Compares an
ObjectRange to another ObjectRange . |
Object |
get(int index) |
Comparable |
getFrom()
The lower value in the range.
|
Comparable |
getTo()
The upper value in the range.
|
protected Object |
increment(Object value)
Increments by one
|
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
|
Iterator |
iterator() |
int |
size() |
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.
|
List |
subList(int fromIndex,
int toIndex) |
String |
toString() |
add, add, addAll, clear, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAll, addAll, clear, containsAll, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public ObjectRange(Comparable from, Comparable to)
from
- the first value in the range.to
- the last value in the range.public ObjectRange(Comparable from, Comparable to, boolean reverse)
public boolean equals(Object that)
equals
in interface Collection
equals
in interface List
equals
in class AbstractList
public boolean equals(ObjectRange that)
ObjectRange
to another ObjectRange
.that
- the object to check equality withtrue
if the ranges are equalpublic Comparable getFrom()
public Comparable getTo()
public boolean isReverse()
public Object get(int index)
get
in interface List
get
in class AbstractList
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
iterator
in class AbstractList
public boolean containsWithinBounds(Object value)
containsWithinBounds
in interface Range
value
- the value of interestpublic int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public List subList(int fromIndex, int toIndex)
subList
in interface List
subList
in class AbstractList
public String toString()
toString
in class AbstractCollection
public String inspect()
public boolean contains(Object value)
contains
in interface Collection
contains
in interface List
contains
in class AbstractCollection
public void step(int step, Closure closure)
public List step(int step)
protected Object increment(Object value)
value
- the value to increment