Function permutator::large_combination_sync
source · [−]pub fn large_combination_sync<'a, T: 'a>(
domain: &'a [T],
r: usize,
result: Arc<RwLock<Vec<&'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 Arc<RwLock<>>.
Parameter
domain : &[T]
- A slice contain a domain to generate r-combinationr : usize
- A size of combination- ’result : Arc<RwLock<Vec<&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.read().unwrap().len()
Rationale
It allow easily safe sharing of result with other thread 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.