Weighted Set
class WeightedSet<E> @JvmOverloads constructor(innerSet: MutableSet<WeightedSet.Element<E>> = mutableSetOf()) : AbstractMutableSet<WeightedSet.Element<E>> (source)
A set containing elements with associated weights. You can retrieve either a specified subset or a single element randomly, with the probability of each element being chosen proportional to its weight.
For example, if you have elements A, B, and C with weights 0.25, 0.25, and 0.5 respectively, element C will be chosen approximately 50% of the time, while A and B will each be chosen about 25% of the time.
Types
Properties
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns a single random element from the set, with selection probability based on weights.
Link copied to clipboard
Returns a random subset of the specified size from the set, with selection probability based on weights. The subset will contain unique elements and always be of the requested size.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard