Groovy Documentation

## 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 java.util.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\$

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

Methods inherited from class java.util.AbstractList

java.util.AbstractList#add(java.lang.Object), java.util.AbstractList#add(int, java.lang.Object), java.util.AbstractList#get(int), java.util.AbstractList#equals(java.lang.Object), java.util.AbstractList#hashCode(), java.util.AbstractList#indexOf(java.lang.Object), java.util.AbstractList#clear(), java.util.AbstractList#lastIndexOf(java.lang.Object), java.util.AbstractList#subList(int, int), java.util.AbstractList#remove(int), java.util.AbstractList#addAll(int, java.util.Collection), java.util.AbstractList#iterator(), java.util.AbstractList#set(int, java.lang.Object), java.util.AbstractList#listIterator(), java.util.AbstractList#listIterator(int), java.util.AbstractList#toString(), java.util.AbstractList#size(), java.util.AbstractList#isEmpty(), java.util.AbstractList#contains(java.lang.Object), java.util.AbstractList#toArray(), java.util.AbstractList#toArray([Ljava.lang.Object;), java.util.AbstractList#remove(java.lang.Object), java.util.AbstractList#addAll(java.util.Collection), java.util.AbstractList#containsAll(java.util.Collection), java.util.AbstractList#removeAll(java.util.Collection), java.util.AbstractList#retainAll(java.util.Collection), java.util.AbstractList#wait(long), java.util.AbstractList#wait(long, int), java.util.AbstractList#wait(), java.util.AbstractList#getClass(), java.util.AbstractList#notify(), java.util.AbstractList#notifyAll(), java.util.AbstractList#size()

Methods inherited from class java.util.AbstractCollection

java.util.AbstractCollection#add(java.lang.Object), java.util.AbstractCollection#toString(), java.util.AbstractCollection#clear(), java.util.AbstractCollection#size(), java.util.AbstractCollection#isEmpty(), java.util.AbstractCollection#contains(java.lang.Object), java.util.AbstractCollection#toArray(), java.util.AbstractCollection#toArray([Ljava.lang.Object;), java.util.AbstractCollection#remove(java.lang.Object), java.util.AbstractCollection#addAll(java.util.Collection), java.util.AbstractCollection#iterator(), java.util.AbstractCollection#containsAll(java.util.Collection), java.util.AbstractCollection#removeAll(java.util.Collection), java.util.AbstractCollection#retainAll(java.util.Collection), java.util.AbstractCollection#wait(long), java.util.AbstractCollection#wait(long, int), java.util.AbstractCollection#wait(), java.util.AbstractCollection#equals(java.lang.Object), java.util.AbstractCollection#hashCode(), java.util.AbstractCollection#getClass(), java.util.AbstractCollection#notify(), java.util.AbstractCollection#notifyAll()

Method Detail

### IntRange

    public java.lang.Object 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 java.lang.Integer#MAX_VALUE values.
  Parameters:
    `from` - the first number in the range.
    `to` - the last number in the range.

### IntRange

    protected java.lang.Object 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(java.lang.Object value)

  {@inheritDoc}

### containsAll

    public boolean containsAll(java.util.Collection other)

  {@inheritDoc}

### containsWithinBounds

    public boolean containsWithinBounds(java.lang.Object o)

### equals

    public boolean equals(java.lang.Object that)

  Determines if this object is equal to another object. Delegates to java.util.AbstractList#equals(java.lang.Object) if `that` is anything other than an IntRange.

  It is not necessary to override `hashCode`, as java.util.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 java.lang.Integer get(int index)

  {@inheritDoc}

### getFrom

    public java.lang.Comparable getFrom()

  {@inheritDoc}

### getFromInt

    public int getFromInt()

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

### getTo

    public java.lang.Comparable getTo()

  {@inheritDoc}

### getToInt

    public int getToInt()

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

### inspect

    public java.lang.String inspect()

  {@inheritDoc}

### isReverse

    public boolean isReverse()

  {@inheritDoc}

### iterator

    public java.util.Iterator iterator()

  {@inheritDoc}

### size

    public int size()

  {@inheritDoc}

### step

    public void step(int step, Closure closure)

  {@inheritDoc}

### step

    public java.util.List step(int step)

  {@inheritDoc}

### subList

    public java.util.List subList(int fromIndex, int toIndex)

  {@inheritDoc}

### toString

    public java.lang.String toString()

  {@inheritDoc}

Groovy Documentation