fn delete_leaf(leaf: usize, beachline: &mut BeachLine) -> (usize, usize, usize, usize) {
    let pred = beachline.predecessor(leaf).unwrap();
    let succ = beachline.successor(leaf).unwrap();
    let parent = beachline.nodes[leaf].parent.unwrap();
    let grandparent = beachline.nodes[parent].parent.unwrap();

    let other = if parent == pred { succ } else { pred };

    // find sibling
    let sibling;
    if beachline.nodes[parent].right_child.unwrap() == leaf {
        sibling = beachline.nodes[parent].left_child.unwrap();
    } else if beachline.nodes[parent].left_child.unwrap() == leaf {
        sibling = beachline.nodes[parent].right_child.unwrap();
    } else {
        panic!("family strife! parent does not acknowledge leaf!");
    }

    // transplant the sibling to replace the parent
    beachline.nodes[sibling].parent = Some(grandparent);
    if beachline.nodes[grandparent].left_child.unwrap() == parent {
        beachline.nodes[grandparent].left_child = Some(sibling);
    } else if beachline.nodes[grandparent].right_child.unwrap() == parent {
        beachline.nodes[grandparent].right_child = Some(sibling);
    } else {
        panic!("family strife! grandparent does not acknowledge parent!");
    }

    // correct the site on 'other'
    if other == pred {
        let new_other_succ = beachline.successor(other).unwrap();
        let new_site = beachline.get_site(new_other_succ).unwrap();
        beachline.set_right_site(other, new_site);
    } else {
        let new_other_pred = beachline.predecessor(other).unwrap();
        let new_site = beachline.get_site(new_other_pred).unwrap();
        beachline.set_left_site(other, new_site);
    }

    (pred, succ, parent, other)
}
// return: indices of predecessor, successor, parent, 'other'
// where 'other' is the one of predecessor or sucessor that
// is not the parent of the leaf.
indices of predecessor, successor, parent, 'other'
where 'other' is the one of predecessor or sucessor that
is not the parent of the leaf.
indices of predecessor successor parent ' other ' where ' other ' is the one of predecessor or sucessor that is not the parent of the leaf .
fn delete_leaf(leaf: usize, beachline: &mut BeachLine) -> (usize, usize, usize, usize) {
    let pred = beachline.predecessor(leaf).unwrap();
    let succ = beachline.successor(leaf).unwrap();
    let parent = beachline.nodes[leaf].parent.unwrap();
    let grandparent = beachline.nodes[parent].parent.unwrap();
    let other = if parent == pred { succ } else { pred };
    // find sibling
    let sibling;
    if beachline.nodes[parent].right_child.unwrap() == leaf {
        sibling = beachline.nodes[parent].left_child.unwrap();
    } else if beachline.nodes[parent].left_child.unwrap() == leaf {
        sibling = beachline.nodes[parent].right_child.unwrap();
    } else {
        panic!("family strife! parent does not acknowledge leaf!");
    }
    // transplant the sibling to replace the parent
    beachline.nodes[sibling].parent = Some(grandparent);
    if beachline.nodes[grandparent].left_child.unwrap() == parent {
        beachline.nodes[grandparent].left_child = Some(sibling);
    } else if beachline.nodes[grandparent].right_child.unwrap() == parent {
        beachline.nodes[grandparent].right_child = Some(sibling);
    } else {
        panic!("family strife! grandparent does not acknowledge parent!");
    }
    // correct the site on 'other'
    if other == pred {
        let new_other_succ = beachline.successor(other).unwrap();
        let new_site = beachline.get_site(new_other_succ).unwrap();
        beachline.set_right_site(other, new_site);
    } else {
        let new_other_pred = beachline.predecessor(other).unwrap();
        let new_site = beachline.get_site(new_other_pred).unwrap();
        beachline.set_left_site(other, new_site);
    }
    (pred, succ, parent, other)
}
fn delete_leaf ( leaf : usize , beachline : & mut BeachLine ) -> ( usize , usize , usize , usize ) { let pred = beachline . predecessor ( leaf ) . unwrap ( ) ; let succ = beachline . successor ( leaf ) . unwrap ( ) ; let parent = beachline . nodes [ leaf ] . parent . unwrap ( ) ; let grandparent = beachline . nodes [ parent ] . parent . unwrap ( ) ; let other = if parent == pred { succ } else { pred } ; // find sibling let sibling ; if beachline . nodes [ parent ] . right_child . unwrap ( ) == leaf { sibling = beachline . nodes [ parent ] . left_child . unwrap ( ) ; } else if beachline . nodes [ parent ] . left_child . unwrap ( ) == leaf { sibling = beachline . nodes [ parent ] . right_child . unwrap ( ) ; } else { panic ! ( " " ) ; } // transplant the sibling to replace the parent beachline . nodes [ sibling ] . parent = Some ( grandparent ) ; if beachline . nodes [ grandparent ] . left_child . unwrap ( ) == parent { beachline . nodes [ grandparent ] . left_child = Some ( sibling ) ; } else if beachline . nodes [ grandparent ] . right_child . unwrap ( ) == parent { beachline . nodes [ grandparent ] . right_child = Some ( sibling ) ; } else { panic ! ( " " ) ; } // correct the site on 'other' if other == pred { let new_other_succ = beachline . successor ( other ) . unwrap ( ) ; let new_site = beachline . get_site ( new_other_succ ) . unwrap ( ) ; beachline . set_right_site ( other , new_site ) ; } else { let new_other_pred = beachline . predecessor ( other ) . unwrap ( ) ; let new_site = beachline . get_site ( new_other_pred ) . unwrap ( ) ; beachline . set_left_site ( other , new_site ) ; } ( pred , succ , parent , other ) }
return: indices of predecessor, successor, parent, 'other'
where 'other' is the one of predecessor or sucessor that
is not the parent of the leaf.
return : indices of predecessor successor parent ' other ' where ' other ' is the one of predecessor or sucessor that is not the parent of the leaf .
leaf
usize
beachline
&mut BeachLine
leaf
usize
beachline
&mut BeachLine