I need an structure kinda like a Map, but I dont care about the key value, only the value correspondent to the key.
On a map, I need to make things like this:
map[1] = "value1"
map[2] = "value2"
It gives me the responsibility to not choose coliding keys. I could solve this by doing:
let handle = randomValue();
map[handle] = "value1"
since I'm not concerned with the value of the key, I only need a handle to it. There's still the problem of coliding values if two random values are equal. I could write a little thing that checks if the key already exists in the map and generate a new one, but once the structure is kinda full, I'll get many collisions.
A List seems a good choice at first, but it's not, since if I remove one element, the indexes of all the others get rearranged.
Instead of implementing my own, I'd like to know if there is already something like this in C++: a map where you get a handle that makes it possible for you to access the value.
I just have another requirement: sometimes I actually need to pass this handle to Rust, so I think that if this handle can be translated to a number and back it'd be very useful.