If you do mind, you could just sum up the all the weights and do the looking up on a second walkthrough. Definitely more memory efficient and if your weights are above 2 on average it would be faster too.
You could also keep a running weight total that would be updated on every addition or deletion in the group.
In reply to Re: Weighted random selection
by jethro
in thread Weighted random selection
by cosmicperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |