Function permutator::large_combination_cell
source · [−]pub fn large_combination_cell<'a, T: 'a>(
domain: &'a [T],
r: usize,
result: Rc<RefCell<&'a mut [&'a T]>>,
cb: impl FnMut()
)
Expand description
Generate a r-combination from given domain and call callback function on each combination. The result will be return into Rc<RefCell<>>.
Parameter
domain : &[T]
- A slice contain a domain to generate r-combinationr : usize
- A size of combination- ’result : Rc<RefCell<&mut [&T]>>` - A result container object.
cb : FnMut()
- A callback that notify caller on each combination
Panic
It panic when r > domain.len()
or r > result.borrow().len()
Rationale
It allow easily safe sharing of result to some degree with minor performance overhead and some some usage constraint.
result
will get overwritten on each new combination.- Storing
result
will get overwritten when new combination is return.