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

  1. domain : &[T] - A slice contain a domain to generate r-combination
  2. r : usize - A size of combination
  3. ’result : Arc<RwLock<Vec<&T>>>` - A result container object.
  4. 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.