Interface SequenceGenerator<T>
- Type Parameters:
T- the type of elements in the sequence
- All Known Implementing Classes:
CyclicIntegerSequence,RandomPermutationCycle
public interface SequenceGenerator<T>
Interface representing a generator of sequences of elements of type T.
Implementations of this interface provide a way to generate sequences of values
that can be iterated through using the generateNext() and getValue() methods.
The sequence can be of any length, as reported by getSequenceLength().
Typical usage:
SequenceGenerator<Integer> generator = ...;
for (int i = 0; i < generator.getSequenceLength(); i++) {
int value = generator.getValue();
// Use the value...
generator.generateNext();
}
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the sequence to the next value.intReturns the length of the sequence before it repeats or resets.getValue()Returns the current value in the sequence.
-
Method Details
-
getValue
-
generateNext
void generateNext()Advances the sequence to the next value. The behavior when called after reaching the end of the sequence is implementation-dependent. Some implementations may cycle back to the beginning, while others may generate new sequences. -
getSequenceLength
int getSequenceLength()Returns the length of the sequence before it repeats or resets.- Returns:
- the number of unique values in the sequence before it repeats
-