generate method
Generates a value according to the given weights
Implementation
@override
T generate() {
int sum = _pool.values.toList().reduce((value, element) => value + element);
int choice = Random(_seed).nextInt(sum) + 1;
for (var pair in _pool.entries) {
if (choice <= pair.value) {
return pair.key;
}
choice -= pair.value;
}
throw Exception(
"Something went wrong while generating weighted pool $_pool");
}