/// <summary> /// Takes a specified number of distinct points from a source /// </summary> /// <param name="random">The random source</param> /// <param name="count">The number of points to take</param> /// <typeparam name="T">The element type</typeparam> public static HashSet <T> TakeSet <T>(this IBoundPointSource <T> random, int count) where T : struct { var src = random.Stream(); var set = src.Take(count).ToHashSet(); while (set.Count < count) { set.AddRange(src.Take(count / 2)); } return(set); }
/// <summary> /// Selects the next sequence of values from the source /// </summary> /// <param name="random">The random source</param> /// <param name="count">The number of values to select</param> /// <typeparam name="T">The value type</typeparam> public static IEnumerable <T> Take <T>(this IBoundPointSource <T> random, int count) where T : struct => random.Stream().Take(count);