package jal.GENERIC;
/**
* A range of values within an array, consisting of the array, the index of
* the first element in the range, and an index one past the range. The
* notation is [first, last)
, indicating that
* array[first]
is part of the range but
* array[last]
is not. The range [n, n)
is a
* valid range that contains zero elements, while
* the range [n, n-1)
is invalid.
*
*
Note that operations on a Range object do not actually change any * array elements. A Range is simply a way of describing a set of values. * *
Copyright © 1996
* Silicon Graphics, Inc.
*
*
Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or
* implied warranty.
*
*
* @author Matthew Austern (austern@mti.sgi.com)
* @author Alexander Stepanov (stepanov@mti.sgi.com)
*/
public final class Range {
/**
* Constructs a Range.
* @param array Array containing the range
* @param first Index of the first element in the range
* @param last Index that is one past the last element in the range
*/
public Range(generic[] array, int first, int last)
{
super();
this.array = array;
this.first = first;
this.last = last;
}
/**
* Constructs a Range that represents an entire array. Equivalent
* to Range(array, 0, array.length)
.
* @param array Array containing the range
*/
public Range(generic[] array)
{
this(array, 0, array.length);
}
/**
* Creates a string representation of this Range.
* @return A string of the form "[first, last)
".
*/
public String toString()
{
return "[" + first + ", " + last + ")";
}
/**
* Array containing the range.
*/
public generic[] array;
/**
* Index of the first element in the range.
*/
public int first;
/**
* Index that is one past the last element in the range.
*/
public int last;
}