1
1

WeightedItem.cs 549 B

123456789101112131415161718192021222324252627
  1. namespace Masuit.Tools.RandomSelector
  2. {
  3. public class WeightedItem<T>
  4. {
  5. /// <summary>
  6. /// 权重
  7. /// </summary>
  8. public int Weight;
  9. /// <summary>
  10. /// 元素
  11. /// </summary>
  12. public readonly T Value;
  13. /// <summary>
  14. /// 累计权重
  15. /// </summary>
  16. internal int CumulativeWeight;
  17. public WeightedItem(T value, int weight)
  18. {
  19. Value = value;
  20. Weight = weight;
  21. CumulativeWeight = 0;
  22. }
  23. }
  24. }