Class NumberPool

Class Documentation

class NumberPool

manages a pool of numbers

Provides function of getting the lowest available number out of a pool of numbers, and the ability to return a number back to the pool. The pool grows as needed. The pool is meant to contain positive integers and if the number would exceed the max value for int, then -1 is returned.

Public Functions

inline NumberPool(int starting_number)

The pool is a set (for automatic sorting) which represents the numbers that are being used, so missing numbers are the available numbers. Constructed with the starting number of the pool

inline int get_next_number()

gets the lowest available number from the pool

This returns the lowest missing value in the set and works because a std::set is auto-sorted.

Returns:

positive int or -1 if pool exceeds max allowed by an int

inline void release_number(int number)

returns indicated number back to the pool

numbers are “returned” by removing them from the set of used numbers

Parameters:

number[in] number to put back into pool