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

## groovy.lang
[Java] Class IntRange

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

All Implemented Interfaces:
  Range

    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.

Authors:
  James Strachan

Version:
  \$Revision: 20589 \$

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)` {@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}
`Comparable` | `getFrom()` {@inheritDoc}
`int` | `getFromInt()` Gets the 'from' value as an integer.
`Comparable` | `getTo()` {@inheritDoc}
`int` | `getToInt()` Gets the 'to' value as an 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}
`String` | `toString()` {@inheritDoc}

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

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

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

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.
  throws:
    IllegalArgumentException if the range would contain more than Integer.MAX_VALUE values.
  Parameters:
    `from` - the first number in the range.
    `to` - the last number in the range.

### IntRange

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

  Creates a new `IntRange`.
  throws:
    IllegalArgumentException if `from` is greater than `to`.
  Parameters:
    `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`.

### 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 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.
  Parameters:
    `that` - the object to compare
  Returns:
    `true` if the objects are equal

### equals

    public boolean equals(IntRange that)

  Compares an IntRange to another IntRange.
  Parameters:
    `that` - the object to compare for equality
  Returns:
    `true` if the ranges are equal

### get

    public Integer get(int index)

  {@inheritDoc}

### getFrom

    public Comparable getFrom()

  {@inheritDoc}

### getFromInt

    public int getFromInt()

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

### getTo

    public Comparable getTo()

  {@inheritDoc}

### getToInt

    public int getToInt()

  Gets the 'to' value as an integer.
  Returns:
    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-2010 The Codehaus. All rights reserved.