|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList
groovy.lang.IntRange
public class IntRange
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.
| Field Summary |
|---|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
|
IntRange(int from,
int to)
Creates a new IntRange. |
protected |
IntRange(int from,
int to,
boolean reverse)
Creates a new IntRange. |
| Method Summary | |
|---|---|
boolean |
contains(Object value)
|
boolean |
containsAll(Collection other)
|
boolean |
containsWithinBounds(Object o)
Indicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from value |
boolean |
equals(IntRange that)
Compares an IntRange to another IntRange. |
boolean |
equals(Object that)
Determines if this object is equal to another object. |
Object |
get(int index)
|
Comparable |
getFrom()
Gets the lower value in the range. |
int |
getFromInt()
Gets the 'from' value as an integer. |
Comparable |
getTo()
Gets the lower value in the range. |
int |
getToInt()
Gets the 'to' value as an integer. |
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()
|
| Methods inherited from class java.util.AbstractList |
|---|
add, add, addAll, clear, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
add, add, addAll, addAll, clear, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, toArray, toArray |
| Constructor Detail |
|---|
public 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.
IllegalArgumentException - if the range would contain more than
Integer.MAX_VALUE values.
protected IntRange(int from,
int to,
boolean reverse)
IntRange.
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.
IllegalArgumentException - if from is greater than to.| Method Detail |
|---|
public boolean equals(Object that)
AbstractList.equals(Object) if that is anthing
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(List,List)
instead of this method.
equals in interface Collectionequals in interface Listequals in class AbstractListthat - the object to compare
true if the objects are equalpublic boolean equals(IntRange that)
IntRange to another IntRange.
that - the object to compare for equality
true if the ranges are equalpublic Comparable getFrom()
getFrom in interface Rangepublic Comparable getTo()
getTo in interface Rangepublic int getFromInt()
public int getToInt()
public boolean isReverse()
isReverse in interface Rangetrue if this is a reverse rangepublic boolean containsWithinBounds(Object o)
Range
containsWithinBounds in interface Rangeo - the object to check against the boundaries of the range
true if the object is between the from and to valuespublic Object get(int index)
get in interface Listget in class AbstractListpublic int size()
size in interface Collectionsize in interface Listsize in class AbstractCollectionpublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listiterator in class AbstractList
public List subList(int fromIndex,
int toIndex)
subList in interface ListsubList in class AbstractListpublic String toString()
toString in class AbstractCollectionpublic String inspect()
inspect in interface RangeString representation of this Range as would be typed into a console
to create the Range instancepublic boolean contains(Object value)
contains in interface Collectioncontains in interface Listcontains in class AbstractCollectionpublic boolean containsAll(Collection other)
containsAll in interface CollectioncontainsAll in interface ListcontainsAll in class AbstractCollection
public void step(int step,
Closure closure)
step in interface Rangestep - the amount by which to step. If negative, steps through the
range backwards.closure - the Closure to callpublic List step(int step)
step in interface Rangestep - the amount by which to step. If negative, steps through the
range backwards.
|
Copyright © 2003-2008 The Codehaus. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||