fromWeightedIterable

fun <E> fromWeightedIterable(iterable: Iterable<E>, weighter: Weighter<E>): RandomSelector<E>

Creates a RandomSelector from a weighted Iterable.

Return

A RandomSelector that selects elements based on their weights.

Parameters

iterable

The iterable collection of elements.

weighter

A function that determines the weight of each element.


Creates a RandomSelector from a weighted Iterable of elements that implement Weighted.

Return

A RandomSelector that selects elements based on their weights.

Parameters

iterable

The iterable collection of elements.