inline PresetChooser::iterator PresetChooser::weightedRandom(bool hardCut) const { // TODO make a sophisticated function object interface to determine why a certain rating // category is chosen, or weighted distribution thereover. const PresetRatingType ratingType = hardCut || (!_softCutRatingsEnabled) ? HARD_CUT_RATING_TYPE : SOFT_CUT_RATING_TYPE; const std::size_t ratingsTypeIndex = static_cast<std::size_t>(ratingType); const std::vector<int> & weights = _presetLoader->getPresetRatings()[ratingsTypeIndex]; const std::size_t index = RandomNumberGenerators::weightedRandom (weights, _presetLoader->getPresetRatingsSums()[ratingsTypeIndex]); return begin(index); }
inline PresetChooser::iterator PresetChooser::weightedRandom() const { std::size_t index = RandomNumberGenerators::weightedRandom (m_presetLoader->getPresetRatings(), m_presetLoader->getPresetRatingsSum()); return begin(index); }