Beispiel #1
0
        public static T ChooseAndExtract <T>(this IRNG random, IList <T> list)
        {
            var index = random.ChooseIndex(list);
            var item  = list[index];

            list.RemoveAt(index);

            return(item);
        }
Beispiel #2
0
        public static T Choose <T>(this IRNG random, IReadOnlyList <T> list)
        {
            var index = random.ChooseIndex(list);

            return(list[index]);
        }
Beispiel #3
0
        public static T Choose <T>(this IRNG random, IReadOnlyCollection <T> items)
        {
            var index = random.ChooseIndex(items);

            return(items.ElementAt(index));
        }