Esempio n. 1
0
        /// <summary>
        /// 添加元素
        /// </summary>
        /// <param name="item"></param>
        public void Add(WeightedItem <T> item)
        {
            if (item.Weight <= 0)
            {
                if (Option.RemoveZeroWeightItems)
                {
                    return;
                }

                throw new InvalidOperationException("权重值不能为0");
            }

            _isAddedCumulativeWeights = true;
            Items.Add(item);
        }
Esempio n. 2
0
 /// <summary>
 /// 移除元素
 /// </summary>
 /// <param name="item"></param>
 public void Remove(WeightedItem <T> item)
 {
     _isAddedCumulativeWeights = true;
     Items.Remove(item);
 }