Package groovy.lang

Class IntRange

All Implemented Interfaces:
Range<Integer>, Iterable<Integer>, Collection<Integer>, List<Integer>, SequencedCollection<Integer>

public class IntRange extends AbstractList<Integer> implements Range<Integer>
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.

Version:
$Revision$
Author:
James Strachan
  • Constructor Details

    • IntRange

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

      protected IntRange(int from, int to, boolean reverse)
      Creates a new IntRange.
      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.
      Throws:
      IllegalArgumentException - if from is greater than to.
  • Method Details