mirror of
https://github.com/ldqk/Masuit.Tools.git
synced 2026-10-27 03:14:14 +08:00
18 lines
423 B
C#
18 lines
423 B
C#
namespace Masuit.Tools.RandomSelector;
|
|
|
|
/// <summary>
|
|
/// 单选器
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
internal class SingleSelector<T> : SelectorBase<T>
|
|
{
|
|
internal SingleSelector(WeightedSelector<T> weightedSelector) : base(weightedSelector)
|
|
{
|
|
}
|
|
|
|
internal T Select()
|
|
{
|
|
return WeightedSelector.Items.Count == 0 ? default : BinarySelect(WeightedSelector.Items).Value;
|
|
}
|
|
}
|