pub fn exhaustive_b_tree_sets_fixed_length<I: Clone + Iterator>(
k: u64,
xs: I,
) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>> ⓘ
Expand description
Generates BTreeSet
s of a given size with elements from a single 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 BTreeSet
.
If xs
is empty, the output is also empty, unless $k$ is 0.
§Examples
use itertools::Itertools;
use malachite_base::sets::exhaustive::exhaustive_b_tree_sets_fixed_length;
use maplit::btreeset;
let xss = exhaustive_b_tree_sets_fixed_length(4, 1..=6).collect_vec();
assert_eq!(
xss,
&[
btreeset! {1, 2, 3, 4},
btreeset! {1, 2, 3, 5},
btreeset! {1, 2, 4, 5},
btreeset! {1, 3, 4, 5},
btreeset! {2, 3, 4, 5},
btreeset! {1, 2, 3, 6},
btreeset! {1, 2, 4, 6},
btreeset! {1, 3, 4, 6},
btreeset! {2, 3, 4, 6},
btreeset! {1, 2, 5, 6},
btreeset! {1, 3, 5, 6},
btreeset! {2, 3, 5, 6},
btreeset! {1, 4, 5, 6},
btreeset! {2, 4, 5, 6},
btreeset! {3, 4, 5, 6}
]
);