org.hackystat.utilities.tstamp
Class TstampSet

java.lang.Object
  extended by org.hackystat.utilities.tstamp.TstampSet

public class TstampSet
extends java.lang.Object

Provides a way to guarantee unique timestamps by keeping track of the old ones and incrementing the millisecond field as needed to create a unique one. The behavior of this class is to return the passed tstamp if it is not already in the set, or else return an incremented version of the tstamp which is incremented enough times to be unique.

Author:
Philip Johnson

Constructor Summary
TstampSet()
          Create a new TstampSet, which is initialized with no knowledge of prior timestamps.
 
Method Summary
 long getUniqueTstamp(long tstamp)
          Return a new unique timestamp based upon the passed timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TstampSet

public TstampSet()
Create a new TstampSet, which is initialized with no knowledge of prior timestamps.

Method Detail

getUniqueTstamp

public long getUniqueTstamp(long tstamp)
Return a new unique timestamp based upon the passed timestamp. If the passed timestamp does not exist in the timestamp set, then it is returned (and it is added to the set). If the passed timestamp already exists in the set, then it is repeatedly incremented until a value is obtained that did not already exist in the timestamp set. This value is then returned (and added to the set.)

Parameters:
tstamp - The tstamp to be used as a basis for finding a unique timestamp.
Returns:
A timestamp that did not previously exist in this TstampSet.