Make random_choose_weighted more general.

It can now accept const vectors of pairs, and also maps (const or not).