org.mbari.siam.distributed
Interface SequenceGenerator

All Known Implementing Classes:
SequenceNumber

public interface SequenceGenerator

A SequenceGenerator generates a (thread-safe) sequence of (long) integers. The sequence may be implemented in a number of ways: simple up/down counters, state machines, table-driven, non-linear functions... The sequence may implement special behavior at the upper/lower limits of the sequence. The SequenceGenerator interface suggests the basic methods needed to implement such counters. A more general purpose approach might be to use this interface as the basis for a number of abstract adapter classes which could be extended to implement sequences of floating point numbers.

Author:
Kent Headley

Method Summary
 long getGreatest()
          Get maximum value in sequence
 long getLeast()
          Get minimum value in sequence
 long getNext()
          Get next number in sequence
 void initialize(long least, long greatest, long current)
          Set sequence range
 long peek(long offset, boolean wrap)
          Look at nth number in sequence (relative to the current number) without actually incrementing.
 void reset()
          Restart sequence from minimum value
 

Method Detail

getNext

long getNext()
Get next number in sequence


getLeast

long getLeast()
Get minimum value in sequence


getGreatest

long getGreatest()
Get maximum value in sequence


initialize

void initialize(long least,
                long greatest,
                long current)
                throws RangeException
Set sequence range

Throws:
RangeException

reset

void reset()
Restart sequence from minimum value


peek

long peek(long offset,
          boolean wrap)
Look at nth number in sequence (relative to the current number) without actually incrementing. The offset may be less than zero. Using an offset of 0 returns the most recent number returned.



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.