IndexAllocator manages integer identifiers in a conservative manner. The identifiers are resources which can be allocated and deallocated, and, if on allocation there are two free identifiers, then the smaller of them is returned. With a proper data structure, this can be done quite efficiently: allocations work in amortized logarithmic time, while deallocations work in logarithmic time.
Allocates integer identifiers conservatively