예제 #1
0
        /// <summary>
        /// Transforms the given collection of strings, and optional collection of weights, to a collection of Weighted string Objects
        /// </summary>
        public static WeightedObject <string>[] ToWeightedStringCollection(this string[] strings, params double[] weights)
        {
            WeightedObject <string>[] chats = new WeightedObject <string> [strings.Length];
            int weightCount = weights.Length;

            for (int i = 0; i < strings.Length; i++)
            {
                chats[i] = new WeightedObject <string>(strings[i], i < weightCount ? weights[i] : 1d);
            }
            return(chats);
        }
예제 #2
0
 /// <summary>
 /// Transforms the given string to a WeightedTuple, holding the string and its weight
 /// </summary>
 public static Tuple <string, double> ToWeightedTuple(this string message, double weight = 1d)
 => WeightedObject <string> .Tuple(message, weight);