// Optimized for permutations near the identity.
// NOTE: Lattice must be reduced so that the voronoi cell fits
//       within the eight unit cells around the origin
Optimized for permutations near the identity.
NOTE: Lattice must be reduced so that the voronoi cell fits
within the eight unit cells around the origin
Optimized for permutations near the identity . NOTE : Lattice must be reduced so that the voronoi cell fits within the eight unit cells around the origin
fn brute_force_set_difference(
    lattice: &Lattice,
    a_fracs: &[V3],
    b_fracs: &[V3],
    tol: f64,
) -> Missing
{
    let mut found_b = vec![false; b_fracs.len()];
    // Same optimization described in from_perm.
    //
    // FIXME: If even a single thing is missing from `to`, then we end up with
    //        quadratic complexity. I think this can be fixed by implementing some
    //        sort of jump list?  Meh.
    let mut search_start = 0;
    let mut only_in_a = vec![];
    'a: for a in 0..a_fracs.len() {
        // Skip through things filled out of order.
        while search_start < b_fracs.len() && found_b[search_start] {
            search_start += 1;
        }
        for b in search_start..b_fracs.len() {
            if found_b[b] {
                continue;
            }
            if fracs_within(lattice, a_fracs[a], b_fracs[b], tol) {
                found_b[b] = true;
                continue 'a;
            }
        }
        only_in_a.push(a);
    }
    let only_in_b = {
        found_b.iter().enumerate()
            .filter(|(_, &x)| !x)
            .map(|(b, _)| b)
            .collect()
    };
    Missing { only_in_a, only_in_b }
}
fn brute_force_set_difference ( lattice : & Lattice , a_fracs : & [ V3 ] , b_fracs : & [ V3 ] , tol : f64 , ) -> Missing { let mut found_b = vec ! [ false b_fracs len ( ) ] ; // Same optimization described in from_perm. // // FIXME: If even a single thing is missing from `to`, then we end up with //        quadratic complexity. I think this can be fixed by implementing some //        sort of jump list?  Meh. let mut search_start = 0 ; let mut only_in_a = vec ! [ ] ; ' a : for a in 0 .. a_fracs . len ( ) { // Skip through things filled out of order. while search_start < b_fracs . len ( ) && found_b [ search_start ] { search_start += 1 ; } for b in search_start .. b_fracs . len ( ) { if found_b [ b ] { continue ; } if fracs_within ( lattice , a_fracs [ a ] , b_fracs [ b ] , tol ) { found_b [ b ] = true ; continue ' a ; } } only_in_a . push ( a ) ; } let only_in_b = { found_b . iter ( ) . enumerate ( ) . filter ( | ( _ , & x ) | ! x ) . map ( | ( b , _ ) | b ) . collect ( ) } ; Missing { only_in_a , only_in_b } }
Optimized for permutations near the identity.
Optimized for permutations near the identity .
lattice
&Lattice
a_fracs
&[V3]
b_fracs
&[V3]
tol
f64