fromInfinityFlow

fun <E> fromInfinityFlow(flow: Flow<E>, weighter: Weighter<E>): RandomSelector<E>

Creates a RandomSelector from an infinite weighted Flow.

Note

The returned RandomSelector does not support pick operation. Use flow to consume elements.

Return

A RandomSelector that emits elements based on their weights.

Parameters

flow

The flow of elements.

weighter

A function that determines the weight of each element.