Combinations and Permutations
Find the combinations and permutations of any collection’s elements, or the product of two different collections.
Combinations
func combinations(ofCount: Int
) -> CombinationsSequence<Self> Returns a collection of combinations of this collection’s elements, with each combination having the specified number of elements.
func combinations<R>(ofCount: R
) -> CombinationsSequence<Self> Returns a collection of combinations of this collection’s elements, with each combination having the specified number of elements.
Permutations
func permutations(ofCount: Int?
) -> PermutationsSequence<Self> Returns a collection of the permutations of this collection of the specified length.
func permutations<R>(ofCount: R
) -> PermutationsSequence<Self> Returns a collection of the permutations of this collection with lengths in the specified range.
Unique Permutations
func uniquePermutations(ofCount: Int?
) -> UniquePermutationsSequence<Self> Returns a sequence of the unique permutations of this sequence of the specified length.
func uniquePermutations<R>(ofCount: R
) -> UniquePermutationsSequence<Self> Returns a collection of the unique permutations of this sequence with lengths in the specified range.
Product
func product<Base1, Base2>(Base1, Base2
) -> Product2Sequence<Base1, Base2> Creates a sequence of each pair of elements of two underlying sequences.
Supporting Types
struct CombinationsSequence<Base>
A collection wrapper that generates combinations of a base collection.
struct PermutationsSequence<Base>
A sequence of all the permutations of a collection’s elements.
struct UniquePermutationsSequence<Base>
A sequence of the unique permutations of the elements of a sequence or collection.
struct Product2Sequence<Base1, Base2>
A sequence that represents the product of two sequences’ elements.