Random Sampling
Choose a specified number of random elements from a sequence or collection.
Random Sampling
func randomSample(count: Int
) -> [Element] Randomly selects the specified number of elements from this sequence.
func randomSample(count: Int
) -> [Element] Randomly selects the specified number of elements from this collection.
func randomStableSample(count: Int
) -> [Element] Randomly selects the specified number of elements from this collection, maintaining their relative order.
Random Sampling with a Generator
func randomSample<G>(count: Int, using: inout G
) -> [Element] Randomly selects the specified number of elements from this sequence.
func randomSample<G>(count: Int, using: inout G
) -> [Element] Randomly selects the specified number of elements from this collection.
func randomStableSample<G>(count: Int, using: inout G
) -> [Element] Randomly selects the specified number of elements from this collection, maintaining their relative order.