pub fn enumerate_indices(
index_domains: Vec<Moo<GroundDomain>>,
) -> impl Iterator<Item = Vec<Literal>>Expand description
For some index domains, returns a list containing each of the possible indices.
Indices are traversed in row-major ordering.
This is an O(n^dim) operation, where dim is the number of dimensions in the matrix.
§Panics
- If any of the index domains are not finite or enumerable with [
Domain::values].
§Example
use std::collections::HashSet;
use conjure_cp_core::ast::{GroundDomain,Moo,Range,Literal,matrix};
let index_domains = vec![Moo::new(GroundDomain::Bool),Moo::new(GroundDomain::Int(vec![Range::Bounded(1,2)]))];
let expected_indices = HashSet::from([
vec![Literal::Bool(false),Literal::Int(1)],
vec![Literal::Bool(false),Literal::Int(2)],
vec![Literal::Bool(true),Literal::Int(1)],
vec![Literal::Bool(true),Literal::Int(2)]
]);
let actual_indices: HashSet<_> = matrix::enumerate_indices(index_domains).collect();
assert_eq!(actual_indices, expected_indices);