|
Groovy 2.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection java.util.AbstractList groovy.lang.IntRange
public class IntRange extends AbstractList
Represents a list of Integer objects from a specified int up (or down) to and including a given to.
This class is a copy of ObjectRange optimized for int
. If you make any
changes to this class, you might consider making parallel changes to ObjectRange.
Instances of this class may be either inclusive aware or non-inclusive aware. See the
relevant constructors for creating each type. Inclusive aware IntRange instances are
suitable for use with Groovy's range indexing - in particular if the from or to values
might be negative. This normally happens underneath the covers but is worth keeping
in mind if creating these ranges yourself explicitly.
Method Summary | |
---|---|
def
|
IntRange(int from, int to)
Creates a new non-inclusive |
protected def
|
IntRange(int from, int to, boolean reverse)
Creates a new non-inclusive aware |
def
|
IntRange(boolean inclusive, int from, int to)
Creates a new inclusive aware |
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)
|
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
|
iterator()
{@inheritDoc} |
int
|
size()
{@inheritDoc} |
void
|
step(int step, Closure closure)
{@inheritDoc} |
List
|
step(int step)
{@inheritDoc} |
List
|
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 AbstractList | |
---|---|
add, add, remove, get, equals, hashCode, indexOf, clear, lastIndexOf, subList, addAll, iterator, set, listIterator, listIterator, remove, toString, contains, isEmpty, size, toArray, toArray, addAll, retainAll, containsAll, removeAll, wait, wait, wait, getClass, notify, notifyAll, size |
Methods inherited from class AbstractCollection | |
---|---|
add, remove, toString, clear, contains, isEmpty, size, toArray, toArray, addAll, iterator, retainAll, containsAll, removeAll, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll |
Method Detail |
---|
public def IntRange(int from, int to)
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.
protected def IntRange(int from, int to, boolean reverse)
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
.
public def IntRange(boolean inclusive, int from, int to)
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.
public boolean contains(Object value)
public boolean containsAll(Collection other)
public boolean containsWithinBounds(Object o)
public boolean equals(Object that)
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 equal
public boolean equals(IntRange that)
that
- the object to compare for equalitytrue
if the ranges are equal
public Integer get(int index)
public Integer getFrom()
public int getFromInt()
public Boolean getInclusive()
public Integer getTo()
public int getToInt()
public String inspect()
public boolean isReverse()
public Iterator iterator()
public int size()
public void step(int step, Closure closure)
public List step(int step)
public List subList(int fromIndex, int toIndex)
public RangeInfo subListBorders(int size)
size
- the size of the aggregate being indexed
public String toString()
Copyright © 2003-2013 The Codehaus. All rights reserved.