public static Func <TValue> Weighted <TValue>(Action <WeightedSetBuilder <TValue> > values) { var builder = new WeightedSetBuilder <TValue>(); values(builder); return(builder.Build()); }
public static Func <TValue> Weighted <TValue>(this IEnumerable <KeyValuePair <TValue, double> > values) { var builder = new WeightedSetBuilder <TValue>(); foreach (var kv in values) { builder.Add(kv.Key, kv.Value); } return(builder.Build()); }
public static Func <TItem> Weighted <TItem>(this IEnumerable <TItem> items, Func <TItem, int, double> weight) { var builder = new WeightedSetBuilder <TItem>(); var i = 0; foreach (var item in items) { builder.Add(item, weight(item, i++)); } return(builder.Build()); }
public TrendBuilder Weighted(Action <WeightedSetBuilder <double> > values, bool pct = false, double weight = 1d) { var builder = new WeightedSetBuilder <double>(); values(builder); var builderValue = builder.Build(); _peaks.Add(new KeyValuePair <IRandomGenerator, double>( new Trend(this, () => MapPercentage(builderValue(), pct, false)), weight)); return(this); }