Class CyclicIntegerSequence
java.lang.Object
org.uma.jmetal.util.sequencegenerator.impl.CyclicIntegerSequence
- All Implemented Interfaces:
SequenceGenerator<Integer>
A thread-safe implementation of
SequenceGenerator that generates a cyclic sequence of
integers from 0 (inclusive) to the specified size (exclusive). When the end of the sequence is
reached, it wraps around to the beginning.
This implementation is thread-safe and can be safely used by multiple threads concurrently.
Example usage:
SequenceGenerator<Integer> sequence = new CyclicIntegerSequence(5);
// Will generate: 0, 1, 2, 3, 4, 0, 1, 2, ...
- Author:
- Antonio J. Nebro
-
Constructor Summary
ConstructorsConstructorDescriptionCyclicIntegerSequence(int size) Creates a new cyclic integer sequence generator. -
Method Summary
-
Constructor Details
-
CyclicIntegerSequence
public CyclicIntegerSequence(int size) Creates a new cyclic integer sequence generator.- Parameters:
size- the size of the sequence (must be positive)- Throws:
IllegalArgumentException- if size is not positive
-
-
Method Details
-
getValue
Description copied from interface:SequenceGeneratorReturns the current value in the sequence.- Specified by:
getValuein interfaceSequenceGenerator<Integer>- Returns:
- the current value in the sequence
-
generateNext
public void generateNext()Description copied from interface:SequenceGeneratorAdvances 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.- Specified by:
generateNextin interfaceSequenceGenerator<Integer>
-
getSequenceLength
public int getSequenceLength()Description copied from interface:SequenceGeneratorReturns the length of the sequence before it repeats or resets.- Specified by:
getSequenceLengthin interfaceSequenceGenerator<Integer>- Returns:
- the number of unique values in the sequence before it repeats
-
toString
-