pub fn shortlex_b_tree_sets<I: Clone + Iterator>(
    xs: I
) -> ShortlexOrderedUniqueCollections<I, BTreeSet<I::Item>> 
where I::Item: Clone + Ord,
Expand description

Generates BTreeSets with elements from a single iterator.

The BTreeSets are generated in order of increasing length, and within each length they 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.

The iterator should be finite; if it is infinite, BTreeSets of length 2 and above will never be generated.

If the input iterator is infinite, the output length is also infinite.

If the input iterator length is $n$, the output length is $2^n$.

If xs is empty, the output consists of a single empty HashSet.

§Examples

#[macro_use]
extern crate maplit;

use itertools::Itertools;
use malachite_base::sets::exhaustive::shortlex_b_tree_sets;

fn main() {
    let xss = shortlex_b_tree_sets(1..=4).collect_vec();
    assert_eq!(
        xss,
        &[
            btreeset!{},
            btreeset!{1},
            btreeset!{2},
            btreeset!{3},
            btreeset!{4},
            btreeset!{1, 2},
            btreeset!{1, 3},
            btreeset!{1, 4},
            btreeset!{2, 3},
            btreeset!{2, 4},
            btreeset!{3, 4},
            btreeset!{1, 2, 3},
            btreeset!{1, 2, 4},
            btreeset!{1, 3, 4},
            btreeset!{2, 3, 4},
            btreeset!{1, 2, 3, 4}
        ]
    );
}