pub fn apply_callback<T>(
        &self,
        head: Option<K>,
        root: Option<K>,
        callback: &mut dyn FnMut(&ReorgNode<K, M>) -> T,
    ) {
        let head = match head {
            Some(head) => head,
            None => match self.nodes_by_height.get(&self.height) {
                Some(heads) => {
                    if heads.len() != 1 {
                        return;
                    } else {
                        heads[0]
                    }
                }
                None => return,
            },
        };
        let head_node = self
            .nodes_by_key
            .get(&head)
            .expect("there in no node stored corresponding to the gived key");
        callback(head_node);
        let mut cursor = head_node.parent;
        while let Some(node) = self.nodes_by_key.get(&cursor) {
            match root {
                Some(root_key) => {
                    if node.key != root_key {
                        cursor = node.parent
                    } else {
                        break;
                    }
                }
                None => {
                    cursor = node.parent;
                }
            }
            callback(node);
        }
    }
/// Apply callback from given head to given root, or as long as possible.
/// If no head is supplied try to go from the highest, but only if
/// there is only one node at the greatest height,
Apply callback from given head to given root, or as long as possible.
If no head is supplied try to go from the highest, but only if
there is only one node at the greatest height.
Apply callback from given head to given root or as long as possible . If no head is supplied try to go from the highest but only if there is only one node at the greatest height .
pub fn apply_callback<T>(
        &self,
        head: Option<K>,
        root: Option<K>,
        callback: &mut dyn FnMut(&ReorgNode<K, M>) -> T,
    ) {
        let head = match head {
            Some(head) => head,
            None => match self.nodes_by_height.get(&self.height) {
                Some(heads) => {
                    if heads.len() != 1 {
                        return;
                    } else {
                        heads[0]
                    }
                }
                None => return,
            },
        };
        let head_node = self
            .nodes_by_key
            .get(&head)
            .expect("there in no node stored corresponding to the gived key");
        callback(head_node);
        let mut cursor = head_node.parent;
        while let Some(node) = self.nodes_by_key.get(&cursor) {
            match root {
                Some(root_key) => {
                    if node.key != root_key {
                        cursor = node.parent
                    } else {
                        break;
                    }
                }
                None => {
                    cursor = node.parent;
                }
            }
            callback(node);
        }
    }
pub fn apply_callback < T > ( & self , head : Option < K > , root : Option < K > , callback : & mut dyn FnMut ( & ReorgNode < K , M > ) -> T , ) { let head = match head { Some ( head ) => head , None => match self . nodes_by_height . get ( & self . height ) { Some ( heads ) => { if heads . len ( ) != 1 { return ; } else { heads [ 0 ] } } None => return , } , } ; let head_node = self . nodes_by_key . get ( & head ) . expect ( " " ) ; callback ( head_node ) ; let mut cursor = head_node . parent ; while let Some ( node ) = self . nodes_by_key . get ( & cursor ) { match root { Some ( root_key ) => { if node . key != root_key { cursor = node . parent } else { break ; } } None => { cursor = node . parent ; } } callback ( node ) ; } }
Apply callback from given head to given root, or as long as possible.
Apply callback from given head to given root or as long as possible .
&self
head
Option<K>
root
Option<K>
callback
&mut dyn FnMut(&ReorgNode<K, M>) -> T
&self
head
Option<K>
root
Option<K>
callback
&mut dyn FnMut(&ReorgNode<K, M>) -> T