javax.media.jai
Class IntegerSequence

java.lang.Object
  |
  +--javax.media.jai.IntegerSequence

public class IntegerSequence
extends Object

A growable sorted integer set. Adding an integer to the sequence results in it being placed into the sequence in sorted order. Adding an integer that is already part of the sequence has no effect.

This structure is used by various subclasses of OpImage to keep track of horizontal and vertical source splits. Each instance of IntegerSequence provides an internal enumeration by means of which the elements of the sequence may be accessed in order. The enumerator is initialized by the startEnumeration method, and the hasMoreElements and nextElement methods allow looping through the elements. Only one enumeration at a time is supported. Calling insert() from multiple threads is not supported.


Constructor Summary
IntegerSequence()
          Constructs a sequence that may contain any integer value.
IntegerSequence(int min, int max)
          Constructs a sequence bounded by an inclusive range of values.
 
Method Summary
 int getNumElements()
          Returns the number of elements contained within this IntegerSequence.
 boolean hasMoreElements()
          Returns true if more elements are available to be iterated over.
 void insert(int element)
          Inserts an integer into the sequence.
 int nextElement()
          Returns the next element of the iteration in ascending order.
 void startEnumeration()
          Resets the iterator to the beginning of the sequence.
 String toString()
          Returns a String representation of the sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerSequence

public IntegerSequence(int min,
                       int max)
Constructs a sequence bounded by an inclusive range of values.
Parameters:
min - Lower bound of the valid integer range.
max - Upper bound of the valid integer range.
Throws:
IllegalArgumentException - if min > max.

IntegerSequence

public IntegerSequence()
Constructs a sequence that may contain any integer value.
Method Detail

insert

public void insert(int element)
Inserts an integer into the sequence. If the value falls out of the desired range, it will be silently rejected. Inserting an element that is already a member of the sequence has no effect.
Parameters:
element - The int to be inserted.

startEnumeration

public void startEnumeration()
Resets the iterator to the beginning of the sequence.

hasMoreElements

public boolean hasMoreElements()
Returns true if more elements are available to be iterated over.

nextElement

public int nextElement()
Returns the next element of the iteration in ascending order. If the end of the array has been reached, a java.util.NoSuchElementException will be thrown.
Throws:
NoSuchElementException - if the end of the array has been reached.

getNumElements

public int getNumElements()
Returns the number of elements contained within this IntegerSequence.

toString

public String toString()
Returns a String representation of the sequence.
Overrides:
toString in class Object