Example #1
0
 /// <summary>
 /// weightで指定した重みをもとに, ランダムに一つを返す. 無い場合は例外
 /// </summary>
 public static TSource Random <TSource>(this IEnumerable <TSource> self, Func <TSource, int> weight)
 {
     return(self.ElementAt(SafeRandom.DiceToss(self.Select(weight))));
 }
Example #2
0
 /// <summary>
 /// ランダムに一つを返す. 無い場合は例外
 /// </summary>
 public static TSource Random <TSource>(this IEnumerable <TSource> self)
 {
     return(self.ElementAt(SafeRandom.Range(0, self.Count())));
 }