Use a lot of bits, increment upon re-use of the slot, and throw when the pattern reaches its maximum.
Alternatively, give each item a unique handle (again counting up) and implement some sort of lookup table to convert those handles into actual indexes.
Alternatively, give each item a unique handle (again counting up) and implement some sort of lookup table to convert those handles into actual indexes.