pub fn heap_permutation_cell<T>(d: &Rc<RefCell<&mut [T]>>, cb: impl FnMut())
Expand description

Heap permutation which permutate variable d in place and call cb function for each permutation done on d.

Parameter

  • d an Rc<RefCell<>> to mutable slice data to be permuted.
  • cb a callback function that will be called several times for each permuted value.

Example

use permutator::heap_permutation_cell;
use std::rc::Rc;
use std::cell::RefCell;
let data : &mut[i32] = &mut [1, 2, 3];
let sharable = Rc::new(RefCell::new(data));
heap_permutation_cell(&sharable, || {
    // call other functions/objects that use `sharable` variable.
});

Warning

The permutation is done in place which mean the parameter d will be mutated.

Notes

  1. The value passed to callback function will equals to value inside parameter d.

Breaking change from 0.3.x to 0.4

Since version 0.4.0, the first result return by this iterator will be the original value