pub fn exhaustive_vec_permutations<T: Clone>(
    xs: Vec<T>
) -> ExhaustiveVecPermutations<T>Notable traits for ExhaustiveVecPermutations<T>impl<T: Clone> Iterator for ExhaustiveVecPermutations<T> type Item = Vec<T>;
Expand description

Generates every permutation of a Vec.

The permutations are Vecs of cloned items. It may be more convenient for the iterator to return references to a slice, in which case you may use exhaustive_slice_permutations. instead.

The permutations are generated in lexicographic order with respect to the ordering in the Vec.

The output length is $n!$, where $n$ is xs.len().

Examples

extern crate itertools;

use itertools::Itertools;
use malachite_base::vecs::exhaustive_vec_permutations;

let css: Vec<String> = exhaustive_vec_permutations(vec!['a', 'b', 'c', 'd'])
    .map(|ds| ds.into_iter().collect())
    .collect();
assert_eq!(
    css.iter().map(String::as_str).collect_vec().as_slice(),
    [
        "abcd", "abdc", "acbd", "acdb", "adbc", "adcb", "bacd", "badc", "bcad", "bcda", "bdac",
        "bdca", "cabd", "cadb", "cbad", "cbda", "cdab", "cdba", "dabc", "dacb", "dbac", "dbca",
        "dcab", "dcba"
    ]
);