Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.0
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.lang
Class IntRange

    java.lang.Object
      java.util.AbstractCollection
          java.util.AbstractList
              groovy.lang.IntRange

All Implemented Interfaces:
  Range

    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.

author:
  James Strachan

version:
  $Revision: 18231 $

Nested Class Summary
`class` | `IntRange.IntRangeIterator` Iterates through each number in an `IntRange`.

Constructor Summary
`IntRange()`

Method Summary
`def` | `IntRange(int from, int to)` Creates a new `IntRange`.
`protected def` | `IntRange(int from, int to, boolean reverse)` Creates a new `IntRange`.
`boolean` | `contains(Object value)` {
`boolean` | `containsAll(Collection other)` {
`boolean` | `containsWithinBounds(Object o)`
`boolean` | `equals(Object that)` Determines if this object is equal to another object.
`boolean` | `equals(IntRange that)` Compares an {
`Integer` | `get(int index)` {
`Comparable` | `getFrom()` {
`int` | `getFromInt()` Gets the 'from' value as an integer.
`Comparable` | `getTo()` {
`int` | `getToInt()` Gets the 'to' value as an integer.
`String` | `inspect()` {
`boolean` | `isReverse()` {
`Iterator` | `iterator()` {
`int` | `size()` {
`void` | `step(int step, Closure closure)` {
`List` | `step(int step)` {
`List` | `subList(int fromIndex, int toIndex)` {
`String` | `toString()` {

Methods inherited from class AbstractList
add, add, get, hashCode, indexOf, clear, equals, lastIndexOf, addAll, iterator, remove, set, listIterator, listIterator, subList, toString, contains, isEmpty, addAll, size, toArray, toArray, remove, containsAll, removeAll, retainAll, wait, wait, wait, getClass, notify, notifyAll, size

Methods inherited from class AbstractCollection
add, clear, toString, contains, isEmpty, addAll, iterator, size, toArray, toArray, remove, containsAll, removeAll, retainAll, wait, wait, wait, hashCode, getClass, equals, notify, notifyAll

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Constructor Detail

### IntRange

    IntRange()

Method Detail

### IntRange

    public def IntRange(int from, int to)

  Creates a new `IntRange`. If `from` is greater than `to`, a reverse range is created with `from` and `to` swapped.
  param:
    from the first number in the range.
  param:
    to the last number in the range.
  throws:
    IllegalArgumentException if the range would contain more than Integer#MAX_VALUE values.

### IntRange

    protected def IntRange(int from, int to, boolean reverse)

  Creates a new `IntRange`.
  param:
    from the first value in the range.
  param:
    to the last value in the range.
  param:
    reverse `true` if the range should count from `to` to `from`.
  throws:
    IllegalArgumentException if `from` is greater than `to`.

### contains

    public boolean contains(Object value)

  {@inheritDoc}

### containsAll

    public boolean containsAll(Collection other)

  {@inheritDoc}

### containsWithinBounds

    public boolean containsWithinBounds(Object o)

### equals

    public boolean equals(Object that)

  Determines if this object is equal to another object. Delegates to 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 instead of this method.
  param:
    that the object to compare
  return:
    `true` if the objects are equal

### equals

    public boolean equals(IntRange that)

  Compares an IntRange to another IntRange.
  return:
    `true` if the ranges are equal
  param:
    that the object to compare for equality

### get

    public Integer get(int index)

  {@inheritDoc}

### getFrom

    public Comparable getFrom()

  {@inheritDoc}

### getFromInt

    public int getFromInt()

  Gets the 'from' value as an integer.
  return:
    the 'from' value as an integer.

### getTo

    public Comparable getTo()

  {@inheritDoc}

### getToInt

    public int getToInt()

  Gets the 'to' value as an integer.
  return:
    the 'to' value as an integer.

### inspect

    public String inspect()

  {@inheritDoc}

### isReverse

    public boolean isReverse()

  {@inheritDoc}

### iterator

    public Iterator iterator()

  {@inheritDoc}

### size

    public int size()

  {@inheritDoc}

### step

    public void step(int step, Closure closure)

  {@inheritDoc}

### step

    public List step(int step)

  {@inheritDoc}

### subList

    public List subList(int fromIndex, int toIndex)

  {@inheritDoc}

### toString

    public String toString()

  {@inheritDoc}

Copyright © 2003-2009 The Codehaus. All rights reserved.