pub fn orbits_self_merge(orbits: &mut Vec<Orbit>) {
    let mut are_orbits_overlapping = true;

    while are_orbits_overlapping {
        are_orbits_overlapping = false;
        for i in 0..orbits.len() {
            // let mut found_intersection = false;
            for j in (i+1)..orbits.len() {
                if  orbit_overlap(&orbits[i], &orbits[j]) {
                    are_orbits_overlapping = true;
                    let mut orbit_j = orbits[j].clone();
                    orbits[i].append(&mut orbit_j);
                    orbits[i].sort_unstable();
                    orbits[i].dedup();
                    orbits.remove(j);
                    break;
                }
            }

            if are_orbits_overlapping {
                break;
            }
        }
    }
}
/// Merge the orbits with common element, until all the orbits are not overlapping
Merge the orbits with common element, until all the orbits are not overlapping
Merge the orbits with common element until all the orbits are not overlapping
pub fn orbits_self_merge(orbits: &mut Vec<Orbit>) {
    let mut are_orbits_overlapping = true;
    while are_orbits_overlapping {
        are_orbits_overlapping = false;
        for i in 0..orbits.len() {
            // let mut found_intersection = false;
            for j in (i+1)..orbits.len() {
                if  orbit_overlap(&orbits[i], &orbits[j]) {
                    are_orbits_overlapping = true;
                    let mut orbit_j = orbits[j].clone();
                    orbits[i].append(&mut orbit_j);
                    orbits[i].sort_unstable();
                    orbits[i].dedup();
                    orbits.remove(j);
                    break;
                }
            }
            if are_orbits_overlapping {
                break;
            }
        }
    }
}
pub fn orbits_self_merge ( orbits : & mut Vec < Orbit > ) { let mut are_orbits_overlapping = true ; while are_orbits_overlapping { are_orbits_overlapping = false ; for i in 0 .. orbits . len ( ) { // let mut found_intersection = false; for j in ( i + 1 ) .. orbits . len ( ) { if orbit_overlap ( & orbits [ i ] , & orbits [ j ] ) { are_orbits_overlapping = true ; let mut orbit_j = orbits [ j ] . clone ( ) ; orbits [ i ] . append ( & mut orbit_j ) ; orbits [ i ] . sort_unstable ( ) ; orbits [ i ] . dedup ( ) ; orbits . remove ( j ) ; break ; } } if are_orbits_overlapping { break ; } } } }
Merge the orbits with common element, until all the orbits are not overlapping
Merge the orbits with common element until all the orbits are not overlapping
orbits
&mut Vec<Orbit>
orbits
&mut Vec<Orbit>