WeightedPoolExtensions
Namespace: Shadop.Archmage.Sdk
Provides Sample and SampleIndex extension methods that draw an item from a
WeightedPool
public static class WeightedPoolExtensionsInheritance Object → WeightedPoolExtensions
Methods
Section titled “Methods”Sample(WeightedPool, Random)
Section titled “Sample(WeightedPool, Random)”Returns a randomly selected item, weighted by the pool’s weights. Throws if the pool is empty or the total weight is zero.
public static T Sample<T>(WeightedPool<T> wp, Random rng)Parameters
Section titled “Parameters”wp WeightedPool
rng Random
Returns
Section titled “Returns”T
SampleIndex(WeightedPool, Random)
Section titled “SampleIndex(WeightedPool, Random)”Returns the index of a randomly selected item, weighted by the pool’s weights. Throws if the pool is empty or the total weight is zero.
public static int SampleIndex<T>(WeightedPool<T> wp, Random rng)Parameters
Section titled “Parameters”wp WeightedPool
rng Random