Exemple #1
0
 /// <summary>
 /// 将乘数中每个键对应的值与自身相应的值相乘
 /// </summary>
 /// <param name="multiplier"></param>
 public void Multiply(Estimable multiplier)
 {
     foreach (string key in multiplier.Keys)
     {
         this[key] *= multiplier[key];
     }
 }
Exemple #2
0
        /// <summary>
        /// 计算
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public double Calculate(T item)
        {
            Estimable weightItem = WeightItem.Clone();

            weightItem.Multiply(item);
            return(weightItem.Sum());
        }
Exemple #3
0
 /// <summary>
 /// 将加数中每个键对应的值与自身相应的值相加
 /// </summary>
 /// <param name="addition"></param>
 public void Add(Estimable addition)
 {
     foreach (string key in addition.Keys)
     {
         this[key] += addition[key];
     }
 }
Exemple #4
0
 /// <summary>
 /// 逐个键比较大小, 若每个键对应的值都大于等于参数, 返回 true, 否则返回 false
 /// </summary>
 /// <param name="target"></param>
 /// <returns></returns>
 public bool CompareTo(Estimable target)
 {
     foreach (string key in Keys)
     {
         if (this[key] < target[key])
         {
             return(false);
         }
     }
     return(true);
 }