示例#1
0
    public List <T> PickN(int n, bool allowDuplicates = true)
    {
        List <T>       ret   = new List <T>();
        RandomPool <T> clone = this.Clone(this);

        for (int i = 0; i < n; i++)
        {
            T pickedValue = clone.PickOne();
            ret.Add(pickedValue);
            if (!allowDuplicates)
            {
                clone.RemoveValue(pickedValue);
            }
        }

        return(ret);
    }