Exemple #1
0
        /// <summary>
        ///     Calculates the cumulative weights if it's needed
        /// </summary>
        public void Build()
        {
            if (!_forceRecalculation)
            {
                return;
            }

            _forceRecalculation = false;
            (_cumulativeWeights, _totalCumulativeWeight) =
                WeightedHelper <T> .CalculateCumulativeWeights(_items, _integerFactor);

            // If the selector don't allow duplicates then it have to create a copy of the weights in list form
            if (!_options.HasFlag(SelectorOptions.AllowDuplicates))
            {
                _cumulativeWeightsList = _cumulativeWeights.ToList();
            }
        }