org.locomotive.util
Class LowNumberKeeper

java.lang.Object
  |
  +--org.locomotive.util.LowNumberKeeper

public class LowNumberKeeper
extends java.lang.Object

manages a pool of numbers. Marks numbers that are used and will not give them out again until they are marked as free. Getting a new number will always give you the lowest available in the set.


Constructor Summary
LowNumberKeeper(int fst, int max)
          creates a new keeper.
 
Method Summary
 void freeNumber(int val)
          Returns the number back to the pool so that others may use it.
 int getNextNumber()
          gets the next available number in the sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LowNumberKeeper

public LowNumberKeeper(int fst,
                       int max)
                throws java.lang.IllegalArgumentException
creates a new keeper. max - first + 1 gives the size of the pool
Parameters:
first - - the first number in the series that is available
Method Detail

getNextNumber

public int getNextNumber()
                  throws java.lang.ArrayIndexOutOfBoundsException
gets the next available number in the sequence.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if no numbers are available

freeNumber

public void freeNumber(int val)
Returns the number back to the pool so that others may use it.
Parameters:
val - the value to be made available in the pool