java.lang.Object
edu.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
|
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 |
idx
int idx
initidx
int initidx
maxidx
int maxidx
increment
int increment
wrapAround
boolean wrapAround
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.
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.