Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.emory.mathcs.util
Class Sequence  view Sequence download Sequence.java

java.lang.Object
  extended byedu.emory.mathcs.util.Sequence

public class Sequence
extends java.lang.Object

Objects of this class produce sequence of integer numbers. Both the initial and max index, as well as the increment, can be specified. This implementation does not allow to reclaim indexes.

Version:
1.0

Field Summary
(package private)  int idx
           
(package private)  int increment
           
(package private)  int initidx
           
(package private)  int maxidx
           
(package private)  boolean wrapAround
           
 
Constructor Summary
Sequence()
          Creates a new sequence with initial index of 0, maximum index of Integer.MAX_VALUE, and increment of 1.
Sequence(int initidx)
          Creates a new sequence with specified initial index, maximum index of Integer.MAX_VALUE, and increment of 1.
Sequence(int initidx, int maxidx)
          Creates a new sequence with specified initial and maximum index, and increment of 1.
Sequence(int initidx, int maxidx, int increment)
          Creates a new sequence with specified initial index, maximum index, and increment.
 
Method Summary
 int next()
          Returns the next index from this sequence.
 void reset()
          Resets this sequence to its initial state.
 void setWrapAround(boolean wrapAround)
          Sets the wrap-around flag for that sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idx

int idx

initidx

int initidx

maxidx

int maxidx

increment

int increment

wrapAround

boolean wrapAround
Constructor Detail

Sequence

public Sequence()
Creates a new sequence with initial index of 0, maximum index of Integer.MAX_VALUE, and increment of 1.


Sequence

public Sequence(int initidx)
Creates a new sequence with specified initial index, maximum index of Integer.MAX_VALUE, and increment of 1.


Sequence

public Sequence(int initidx,
                int maxidx)
Creates a new sequence with specified initial and maximum index, and increment of 1.


Sequence

public Sequence(int initidx,
                int maxidx,
                int increment)
Creates a new sequence with specified initial index, maximum index, and increment.

Method Detail

setWrapAround

public void setWrapAround(boolean wrapAround)
Sets the wrap-around flag for that sequence. If the flag is true, the sequence is allowed to start over if it reached the max index. Otherwise, it would throw IllegalStateException. By default, this flag is set to false.


next

public int next()
Returns the next index from this sequence.


reset

public void reset()
Resets this sequence to its initial state.