Function malachite_base::sets::exhaustive::lex_hash_sets_fixed_length
source · pub fn lex_hash_sets_fixed_length<I: Iterator>(
k: u64,
xs: I,
) -> LexFixedLengthOrderedUniqueCollections<I, HashSet<I::Item>> ⓘ
Expand description
Generates HashSet
s of a given size with elements from a single iterator.
The HashSet
s are ordered lexicographically with respect to the order of the element
iterator.
The source iterator should not repeat any elements, but this is not enforced.
If $k$ is 0, the output length is 1.
If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.
If $k$ is nonzero and the input iterator length is $n$, the output length is $\binom{n}{k}$.
If $k$ is 0, the output consists of one empty HashSet
.
If xs
is empty, the output is also empty, unless $k$ is 0.
§Examples
use itertools::Itertools;
use malachite_base::sets::exhaustive::lex_hash_sets_fixed_length;
use maplit::hashset;
let xss = lex_hash_sets_fixed_length(4, 1..=6).collect_vec();
assert_eq!(
xss,
&[
hashset! {1, 2, 3, 4},
hashset! {1, 2, 3, 5},
hashset! {1, 2, 3, 6},
hashset! {1, 2, 4, 5},
hashset! {1, 2, 4, 6},
hashset! {1, 2, 5, 6},
hashset! {1, 3, 4, 5},
hashset! {1, 3, 4, 6},
hashset! {1, 3, 5, 6},
hashset! {1, 4, 5, 6},
hashset! {2, 3, 4, 5},
hashset! {2, 3, 4, 6},
hashset! {2, 3, 5, 6},
hashset! {2, 4, 5, 6},
hashset! {3, 4, 5, 6}
]
);