public class IntRange extends AbstractList
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Type | Name and description |
---|---|
def |
IntRange(int from, int to) Creates a new non-inclusive IntRange . |
protected def |
IntRange(int from, int to, boolean reverse) Creates a new non-inclusive aware IntRange . |
def |
IntRange(boolean inclusive, int from, int to) Creates a new inclusive aware IntRange . |
boolean |
contains(Object value) {@inheritDoc} |
boolean |
containsAll(Collection other) {@inheritDoc} |
boolean |
containsWithinBounds(Object o) |
boolean |
equals(Object that) Determines if this object is equal to another object. |
boolean |
equals(IntRange that) Compares an IntRange to another IntRange. |
Integer |
get(int index) {@inheritDoc} |
Integer |
getFrom() {@inheritDoc} |
int |
getFromInt() Gets the 'from' value as a primitive integer. |
Boolean |
getInclusive() Returns the inclusive flag. |
Integer |
getTo() {@inheritDoc} |
int |
getToInt() Gets the 'to' value as a primitive integer. |
String |
inspect() {@inheritDoc} |
boolean |
isReverse() {@inheritDoc} |
Iterator<Integer> |
iterator() {@inheritDoc} |
int |
size() {@inheritDoc} |
void |
step(int step, Closure closure) {@inheritDoc} |
List<Integer> |
step(int step) {@inheritDoc} |
List<Integer> |
subList(int fromIndex, int toIndex) {@inheritDoc} |
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. |
String |
toString() {@inheritDoc} |
Methods inherited from class | Name |
---|---|
class AbstractList |
add, add, remove, get, equals, hashCode, indexOf, clear, lastIndexOf, subList, addAll, iterator, set, listIterator, listIterator, remove, toString, contains, isEmpty, size, toArray, toArray, addAll, containsAll, removeAll, retainAll, wait, wait, wait, getClass, notify, notifyAll, size |
class AbstractCollection |
add, remove, toString, clear, contains, isEmpty, size, toArray, toArray, addAll, iterator, containsAll, removeAll, retainAll, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll |
Creates a new non-inclusive IntRange
. If from
is greater than
to
, a reverse range is created with from
and to
swapped.
from
- the first number in the range.to
- the last number in the range. Creates a new non-inclusive aware IntRange
.
from
is greater than to
.from
- the first value in the range.to
- the last value in the range.reverse
- true
if the range should count from
to
to from
. Creates a new inclusive aware IntRange
.
from
- the first value in the range.to
- the last value in the range.inclusive
- true
if the to value is included in the range.{@inheritDoc}
{@inheritDoc}
Determines if this object is equal to another object. Delegates to
AbstractList.equals if that
is anything
other than an IntRange.
It is not necessary to override hashCode
, as
AbstractList.hashCode provides a suitable hash code.
Note that equals is generally handled by DefaultGroovyMethods.equals instead of this method.
that
- the object to comparetrue
if the objects are equalCompares an IntRange to another IntRange.
that
- the object to compare for equalitytrue
if the ranges are equal{@inheritDoc}
{@inheritDoc}
Gets the 'from' value as a primitive integer.
Returns the inclusive flag. Null for non-inclusive aware ranges or non-null for inclusive aware ranges.
{@inheritDoc}
Gets the 'to' value as a primitive integer.
{@inheritDoc}
{@inheritDoc}
{@inheritDoc}
{@inheritDoc}
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.
size
- the size of the aggregate being indexed{@inheritDoc}