| Modifier and Type | Class and Description |
|---|---|
| private static class | ObjectRange.StepIterator
Non-thread-safe iterator which lazily produces the next element only on calls of hasNext() or next() |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparable | from
The first value in the range. |
| private final boolean | reverse
|
| private int | size
The cached size, or -1 if not yet computed |
| private final Comparable | to
The last value in the range. |
| Access | Constructor and Description |
|---|---|
| public | ObjectRange(Comparable<T>
the first value in the range. from, Comparable<T> the last value in the range. to)Creates a new |
| public | ObjectRange(Comparable<T> smaller, Comparable<T> larger, boolean reverse)
Creates a new |
| private | ObjectRange(Comparable<T>
start of the range, must no be larger than to when reverse != null smaller, Comparable<T> end of the range, must be larger than from when reverse != null larger, Boolean direction of the range. If null, causes direction to be computed (can be expensive). reverse)Constructs a Range, computing reverse if not provided. |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | |
| protected void | checkBoundaryCompatibility()
throws IllegalArgumentException if to and from are incompatible, meaning they e.g. (likely) produce infinite sequences. |
| protected int | |
| public boolean | contains(Object
element whose presence in this list is to be tested value)Overrides java. Implements java. |
| public boolean | Returns: true if the value is within the boundsthe value of interest value)Implements groovy. |
| protected Object | |
| public boolean | equals(Object
the object to be compared for equality with this list that)Overrides java. Implements java. |
| public boolean | Returns: true if the ranges are equalthe object to check equality with that)Compares an |
| public Comparable | get(int
index of the element to return index)Implements abstract java. Implements java. |
| public Comparable | |
| public Comparable | |
| protected Object | |
| public String | |
| public boolean | isReverse()
Implements groovy. |
| public Iterator | iterator()
Overrides java. Implements java. |
| private static Comparable | normaliseStringType(final Comparable<T> operand)
if operand is a Character or a String with one character, return that character's int value. |
| private void | |
| public int | size()
Implements abstract java. Implements java. |
| public void | step(int
the amount by which to step. If negative, steps through the range backwards. step, Closure<V> the closure)Closure to callImplements groovy. |
| public List | step(int
the amount by which to step. If negative, steps through the range backwards. step)Implements groovy. |
| public List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Overrides java. Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| public String | toString()
Overrides java. |
| from | back to summary |
|---|---|
| private final Comparable<T> from The first value in the range. | |
| reverse | back to summary |
|---|---|
| private final boolean reverse
| |
| size | back to summary |
|---|---|
| private int size The cached size, or -1 if not yet computed | |
| to | back to summary |
|---|---|
| private final Comparable<T> to The last value in the range. | |
| ObjectRange | back to summary |
|---|---|
| public ObjectRange(Comparable<T> from, Comparable<T> to) Creates a new
| |
| ObjectRange | back to summary |
|---|---|
| public ObjectRange(Comparable<T> smaller, Comparable<T> larger, boolean reverse) Creates a new Optimized Constructor avoiding initial computation of comparison. | |
| ObjectRange | back to summary |
|---|---|
| private ObjectRange(Comparable<T> smaller, Comparable<T> larger, Boolean reverse) Constructs a Range, computing reverse if not provided. When providing reverse, 'smaller' must not be larger than 'larger'.
| |
| areReversed | back to summary |
|---|---|
| private static boolean areReversed(Comparable<T> from, Comparable<T> to) | |
| checkBoundaryCompatibility | back to summary |
|---|---|
| protected void checkBoundaryCompatibility() throws IllegalArgumentException if to and from are incompatible, meaning they e.g. (likely) produce infinite sequences. Called at construction time, subclasses may override cautiously (using only members to and from). | |
| compareTo | back to summary |
|---|---|
| protected int compareTo(Comparable<T> first, Comparable<T> second) | |
| contains | back to summary |
|---|---|
| public boolean contains(Object value) Overrides java. Implements java. Iterates over all values and returns true if one value matches.
| |
| containsWithinBounds | back to summary |
|---|---|
| public boolean containsWithinBounds(Object value) Implements groovy. Checks whether a value is between the from and to values of a Range | |
| decrement | back to summary |
|---|---|
| protected Object decrement(Object value) Decrements by one | |
| equals | back to summary |
|---|---|
| public boolean equals(Object that) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| equals | back to summary |
|---|---|
| public boolean equals(ObjectRange that) Compares an
| |
| get | back to summary |
|---|---|
| public Comparable Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| getFrom | back to summary |
|---|---|
| public Comparable Implements groovy. Doc from groovy. The lower value in the range.
| |
| getTo | back to summary |
|---|---|
| public Comparable Implements groovy. Doc from groovy. The upper value in the range.
| |
| increment | back to summary |
|---|---|
| protected Object increment(Object value) Increments by one | |
| inspect | back to summary |
|---|---|
| public String inspect() Implements groovy. | |
| isReverse | back to summary |
|---|---|
| public boolean isReverse() Implements groovy. Doc from groovy. Indicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from value
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides java. Implements java. Doc from java. Returns an iterator over the elements in this list in proper sequence.
| |
| normaliseStringType | back to summary |
|---|---|
| private static Comparable if operand is a Character or a String with one character, return that character's int value. | |
| setSize | back to summary |
|---|---|
| private void setSize(int size) protection against calls from Groovy
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| step | back to summary |
|---|---|
| public void step(int step, Closure<V> closure) Implements groovy. Doc from groovy. Steps through the range, calling a closure for each item. | |
| step | back to summary |
|---|---|
| public List Implements groovy. Doc from groovy. Forms a list by stepping through the range by the indicated interval.
| |
| subList | back to summary |
|---|---|
| public List Overrides java. Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of this collection. The string
representation consists of a list of the collection's elements in the
order they are returned by its iterator, enclosed in square brackets
(
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private boolean | |
| private final ObjectRange | |
| private final int | |
| private Comparable |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Comparable | |
| private Comparable | |
| public void | remove()
Overrides default java. |
| index | back to summary |
|---|---|
| private int index | |
| nextFetched | back to summary |
|---|---|
| private boolean nextFetched | |
| range | back to summary |
|---|---|
| private final ObjectRange range | |
| step | back to summary |
|---|---|
| private final int step | |
| value | back to summary |
|---|---|
| private Comparable<T> value | |
| StepIterator | back to summary |
|---|---|
| private StepIterator(ObjectRange range, final int desiredStep) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Comparable Implements java. Doc from java. Returns the next element in the iteration.
| |
| peek | back to summary |
|---|---|
| private Comparable | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |