pub fn random_unique_vecs<I: Iterator>(
    seed: Seed,
    xs_gen: &dyn Fn(Seed) -> I,
    mean_length_numerator: u64,
    mean_length_denominator: u64
) -> RandomUniqueVecs<I::Item, GeometricRandomNaturalValues<u64>, I> where
    I::Item: Eq + Hash,
Expand description

Generates random Vecs using elements from an iterator, where the Vecs have no repeated elements.

The lengths of the Vecs are sampled from a geometric distribution with a specified mean $m$, equal to mean_length_numerator / mean_length_denominator. $m$ must be greater than 0.

Strictly speaking, the input iterator must generate infinitely many distinct elements. In practice it only needs to generate $k$ distinct elements, where $k$ is the largest length actually sampled from the geometric distribution. For example, if mean_length_numerator / mean_length_denominator is significantly lower than 256, then it’s ok to use random_unsigneds::<u8>.

xs_gen must be infinite.

Panics

Panics if mean_length_numerator or mean_length_denominator are zero, or, if after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.

Examples

use itertools::Itertools;
use malachite_base::num::random::random_primitive_ints;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::vecs::random::random_unique_vecs;

let xs = random_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);
let values = xs.take(20).collect_vec();
assert_eq!(
    values.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[][..],
        &[85, 11, 136, 200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166],
        &[234, 30, 218, 90],
        &[106, 9, 216, 204],
        &[151],
        &[],
        &[213, 97, 253, 78, 91],
        &[39, 191],
        &[175, 170, 232, 233],
        &[],
        &[2, 35, 22, 217, 198, 114],
        &[],
        &[],
        &[17, 32, 173, 114, 65, 121, 222, 25, 144, 148, 79],
        &[115, 52, 73, 69, 137, 91, 153, 178],
        &[],
        &[112, 34, 95],
        &[],
        &[106, 167, 197, 130, 168],
        &[122, 207, 172, 177, 86, 150, 221, 218, 101]
    ]
);