A class for allocating integers from a given range that uses a {@link BitSet} representation of the free integers.
Concurrent Semantics: This class is
not thread safe.
Implementation notes: This was originally an ordered chain of non-overlapping Intervals, together with a fixed size array cache for freed integers.
{@link #reserve()} was expensive in this scheme, whereas in thepresent implementation it is O(1), as is {@link #free()}.
Although {@link #allocate()} is slightly slower than O(1) and in theworst case could be O(N), the use of the {@link #lastIndex} fieldfor starting the next scan for free integers means this is negligible.
The data representation overhead is O(N) where N is the size of the allocation range. One
long
is used for every 64 integers in the range.
Very little Object creation and destruction occurs in use.