示例#1
0
        public static Func <TValue> Weighted <TValue>(Action <WeightedSetBuilder <TValue> > values)
        {
            var builder = new WeightedSetBuilder <TValue>();

            values(builder);
            return(builder.Build());
        }
示例#2
0
        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());
        }
示例#3
0
        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());
        }
示例#4
0
        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);
        }