Closed soulne4ny closed 12 years ago
Added WeightedArray.
Yaroslav found more elegant solution that uses TreeMap
-- http://stackoverflow.com/questions/6409652/random-weighted-selection-java-framework. However, efficiency is the same.
On each step random elements appear in different amount. It's a bug.
Add remove(value)
method and switch to RandomCell to the same algorithm. Switch to TreeMap
implemention because of it.
To add remove is bad idea, because remove(value)
will take O(n)
. TreeMap
won't help to make it faster.
Implemented WeightedArrayOfStrings
with tests.
Store element key (string) with its weight. Currently integer weights are enough.