I'm writing a program, currently using vectors, that needs to store data (atoms that move with particular probabilities) in such a way that it can be efficiently picked with a biased random probability.
At the moment vectors seem great for this as I can just assign multiple sites to one probability then pick a random site (so if atom a has a relative probability of 0.6 of being picked, and atom b has 0.4, i can assign 3 elements to a and 2 to b then randomly pick any element)
However then i need to remove all sites relating to the picked atom, which in a vector means finding them (or storing their locations separately), swapping them to the end and using push_back. Depending on how I do this it either seems to be very slow or very memory intensive.
It seems like hashtables might be a better structure to use, as these would allow me to look up sites relating to a particular atom more easily, but could i still use the same weighted picking mechanism with a hashtable?
I've never used hashtabes before, are there any other complications? Or is there another structure that I should look into that would be even better?