randomSample(count:using:)

Randomly selects the specified number of elements from this sequence.

RandomSample.swift:183
func randomSample<G>(count k: Int, using rng: inout G) -> [Element] where G : RandomNumberGenerator

Parameters

k

The number of elements to randomly select.

rng

The random number generator to use for the sampling.

Returns

An array of k random elements. The returned elements may be in any order. If k is greater than this sequence’s count, then this method returns the full sequence.