| Modifier and Type | Class and Description |
|---|---|
| private class | NumberRange.StepIterator
convenience class to serve in other methods. |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparable | from
The first value in the range. |
| private Integer | hashCodeCache
The cached hashCode (once calculated) |
| private final boolean | inclusive
|
| private final boolean | reverse
|
| private static final long | |
| private int | size
The cached size, or -1 if not yet computed |
| private final Number | stepSize
The step size in the range. |
| private final Comparable | to
The last value in the range. |
| Access | Constructor and Description |
|---|---|
| public <T extends Number & Comparable | NumberRange(T
the first value in the range from, U the last value in the range to)Creates an inclusive |
| public <T extends Number & Comparable | NumberRange(T
start of the range from, U end of the range to, boolean whether the range is inclusive inclusive)Creates a new |
| public <T extends Number & Comparable | NumberRange(T
start of the range from, U end of the range to, V the gap between discrete elements in the range stepSize)Creates an inclusive |
| public <T extends Number & Comparable | NumberRange(T
start of the range from, U end of the range to, V the gap between discrete elements in the range stepSize, boolean whether the range is inclusive inclusive)Creates a |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | |
| public <T extends Number & Comparable | Returns: a new NumberRangethe desired step size stepSize)For a NumberRange with step size 1, creates a new NumberRange with the same
|
| pack-priv void | |
| pack-priv static <T extends Number & Comparable | |
| pack-priv static <T extends Number & Comparable | |
| 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. |
| private Comparable | |
| public boolean | Returns: true if the specified object is equal to this NumberRangethe object to be compared for equality with this NumberRange that)Overrides java. Implements java. |
| public boolean | Returns: true if the ranges are equalthe NumberRange to check equality with that)Compares a |
| public Comparable | get(int
index of the element to return index)Implements abstract java. Implements java. |
| public Comparable | |
| public Comparable | |
| public Comparable | |
| private String | |
| public int | Returns: the hashCode valueOverrides java. Implements java. |
| private Comparable | |
| public String | |
| private boolean | |
| public boolean | isReverse()
Implements groovy. |
| public Iterator | iterator()
Overrides java. Implements java. |
| 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. numSteps, 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. numSteps)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 RangeInfo | Returns: the calculated range information (with 1 added to the to value, ready for providing to subListthe size of the aggregate being indexed size)A method for determining from and to information when using this IntRange to index an aggregate object of the specified size. |
| public String | toString()
Overrides java. |
| from | back to summary |
|---|---|
| private final Comparable<T> from The first value in the range. | |
| hashCodeCache | back to summary |
|---|---|
| private Integer hashCodeCache The cached hashCode (once calculated) | |
| inclusive | back to summary |
|---|---|
| private final boolean inclusive
| |
| reverse | back to summary |
|---|---|
| private final boolean reverse
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| size | back to summary |
|---|---|
| private int size The cached size, or -1 if not yet computed | |
| stepSize | back to summary |
|---|---|
| private final Number stepSize The step size in the range. | |
| to | back to summary |
|---|---|
| private final Comparable<T> to The last value in the range. | |
| NumberRange | back to summary |
|---|---|
| public <T extends Number & Comparable Creates an inclusive
| |
| NumberRange | back to summary |
|---|---|
| public <T extends Number & Comparable Creates a new
| |
| NumberRange | back to summary |
|---|---|
| public <T extends Number & Comparable Creates an inclusive
| |
| NumberRange | back to summary |
|---|---|
| public <T extends Number & Comparable Creates a
| |
| areReversed | back to summary |
|---|---|
| private static boolean areReversed(Number from, Number to) | |
| by | back to summary |
|---|---|
| public <T extends Number & Comparable For a NumberRange with step size 1, creates a new NumberRange with the same
| |
| calcSize | back to summary |
|---|---|
| pack-priv void calcSize(Comparable<T> from, Comparable<T> to, Number stepSize) | |
| comparableNumber | back to summary |
|---|---|
pack-priv static <T extends Number & Comparable
| |
| comparableNumber | back to summary |
|---|---|
pack-priv static <T extends Number & Comparable
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object value) Overrides java. Implements java. iterates over all values and returns true if one value matches. Also see containsWithinBounds.
| |
| 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 |
|---|---|
| private Comparable Decrements by given step
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object that) Overrides java. Implements java. An object is deemed equal to this NumberRange if it represents a List of items and those items equal the list of discrete items represented by this NumberRange.
| |
| fastEquals | back to summary |
|---|---|
| public boolean fastEquals(NumberRange that) Compares a
| |
| 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.
| |
| getStepSize | back to summary |
|---|---|
| public Comparable | |
| getTo | back to summary |
|---|---|
| public Comparable Implements groovy. Doc from groovy. The upper value in the range.
| |
| getToString | back to summary |
|---|---|
| private String getToString(String toText, String fromText) | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. A NumberRange's hashCode is based on hashCode values of the discrete items it represents.
| |
| increment | back to summary |
|---|---|
| private Comparable Increments by given step
| |
| inspect | back to summary |
|---|---|
| public String inspect() Implements groovy. | |
| isIntegral | back to summary |
|---|---|
| private boolean isIntegral(Number stepSize) | |
| 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.
| |
| 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 numSteps, 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.)
| |
| subListBorders | back to summary |
|---|---|
| public RangeInfo subListBorders(int size) A method for determining from and to information when using this IntRange to index an aggregate object of the specified size. Normally only used internally within Groovy but useful if adding range indexing support for your own aggregates.
| |
| 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 final boolean | |
| private boolean | |
| private Comparable | |
| private final NumberRange | |
| private final Number |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | |
| public Comparable | |
| public void | remove()
Overrides default java. |
| isAscending | back to summary |
|---|---|
| private final boolean isAscending | |
| isNextFetched | back to summary |
|---|---|
| private boolean isNextFetched | |
| next | back to summary |
|---|---|
| private Comparable<T> next | |
| range | back to summary |
|---|---|
| private final NumberRange range | |
| step | back to summary |
|---|---|
| private final Number step | |
| StepIterator | back to summary |
|---|---|
| pack-priv StepIterator(NumberRange range, Number step) | |
| fetchNextIfNeeded | back to summary |
|---|---|
| private void fetchNextIfNeeded() | |
| 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.
| |
| 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
| |