pub fn cayley_dist<K: OrDistElement>(v1: &[K], v2: &[K]) -> Result<usize, OrDistError<K>> {
    let (_, mut om2) = ordmaps_identical_owned(v1, v2)?;
    let mut v2 = Vec::from(v2);
    let mut ans = 0;
    for (i, e) in v1.iter().enumerate() {
        let exchange_val = om2.get(&e);
        if exchange_val != i {
            let exchange_key = v2[i].to_owned();
            swap_ordmap(&mut om2, &e, &&exchange_key);
            swap_vec(&mut v2, i, exchange_val);
            ans += 1;
        }
    }
    Ok(ans)
}
/// Cayley distance between 2 orders.
/// 
/// The minimum number of procedures to exchange any element of `v2` 
/// that is required to convert `v2` to `v1`.
Cayley distance between 2 orders.
Cayley distance between 2 orders .
pub fn cayley_dist<K: OrDistElement>(v1: &[K], v2: &[K]) -> Result<usize, OrDistError<K>> {
    let (_, mut om2) = ordmaps_identical_owned(v1, v2)?;
    let mut v2 = Vec::from(v2);
    let mut ans = 0;
    for (i, e) in v1.iter().enumerate() {
        let exchange_val = om2.get(&e);
        if exchange_val != i {
            let exchange_key = v2[i].to_owned();
            swap_ordmap(&mut om2, &e, &&exchange_key);
            swap_vec(&mut v2, i, exchange_val);
            ans += 1;
        }
    }
    Ok(ans)
}
pub fn cayley_dist < K : OrDistElement > ( v1 : & [ K ] , v2 : & [ K ] ) -> Result < usize , OrDistError < K > > { let ( _ , mut om2 ) = ordmaps_identical_owned ( v1 , v2 ) ? ; let mut v2 = Vec :: from ( v2 ) ; let mut ans = 0 ; for ( i , e ) in v1 . iter ( ) . enumerate ( ) { let exchange_val = om2 . get ( & e ) ; if exchange_val != i { let exchange_key = v2 [ i ] . to_owned ( ) ; swap_ordmap ( & mut om2 , & e , & & exchange_key ) ; swap_vec ( & mut v2 , i , exchange_val ) ; ans += 1 ; } } Ok ( ans ) }
Cayley distance between 2 orders.
Cayley distance between 2 orders .
v1
&[K]
v2
&[K]
v1
&[K]
v2
&[K]