So you want an integer set? DO you have any constraints on memory use?
Are those in a specific range like 0 ..< N?
If yes you may reuse the ideas between sparse sets, which I use to support
random sampling for Monte Carlo Tree Search (game simulations, perf bottleneck
for IA algorithm) and for my multithreading runtime:
*
[https://github.com/mratsim/golem-prime/blob/master/src/core/c_empty_points.nim](https://github.com/mratsim/golem-prime/blob/master/src/core/c_empty_points.nim)
*
[https://github.com/mratsim/weave/blob/master/weave/datatypes/sparsesets.nim](https://github.com/mratsim/weave/blob/master/weave/datatypes/sparsesets.nim)
You keep 2 arrays: one that maps a key to a position in a second array, the
second arrays stores the actual value.