fn resolve(&self, index: NodeIndex, exclusion_list: &HashSet<&LeafIndex>) -> Vec<NodeIndex> {
        let size = self.leaf_count();

        // We end the recursion at leaf level
        if self.nodes[index].node_type == NodeType::Leaf {
            if self.nodes[index].is_blank()
                // We can unwrap here, because we just checked that the node is
                // indeed a leaf.
                || exclusion_list.contains(&LeafIndex::try_from(index).unwrap())
            {
                return vec![];
            } else {
                return vec![index];
            }
        }

        // If a node is not blank, the resolution consists of that node's index,
        // as well as its unmerged leaves.
        if !self.nodes[index].is_blank() {
            let mut resolution = vec![index];
            let node = self.nodes[index].node.as_ref();
            resolution.extend(
                node.unwrap()
                    .unmerged_leaves()
                    .iter()
                    .filter(|resolution_node| !exclusion_list.contains(resolution_node))
                    .map(|&n| NodeIndex::from(n)),
            );
            resolution
        } else {
            // Otherwise we take the resolution of the children
            // Unwrapping here is safe, since parent nodes always have children
            let mut left = self.resolve(treemath::left(index).unwrap(), exclusion_list);
            let right = self.resolve(treemath::right(index, size).unwrap(), exclusion_list);
            // We concatenate the resolution and return it
            left.extend(right);
            left
        }
    }
/// Compute the resolution for a given node index. Leaves listed in the
/// `exclusion_list` are subtracted from the final resolution.
Compute the resolution for a given node index. Leaves listed in the
`exclusion_list` are subtracted from the final resolution.
Compute the resolution for a given node index . Leaves listed in the ` exclusion_list ` are subtracted from the final resolution .
fn resolve(&self, index: NodeIndex, exclusion_list: &HashSet<&LeafIndex>) -> Vec<NodeIndex> {
        let size = self.leaf_count();
        // We end the recursion at leaf level
        if self.nodes[index].node_type == NodeType::Leaf {
            if self.nodes[index].is_blank()
                // We can unwrap here, because we just checked that the node is
                // indeed a leaf.
                || exclusion_list.contains(&LeafIndex::try_from(index).unwrap())
            {
                return vec![];
            } else {
                return vec![index];
            }
        }
        // If a node is not blank, the resolution consists of that node's index,
        // as well as its unmerged leaves.
        if !self.nodes[index].is_blank() {
            let mut resolution = vec![index];
            let node = self.nodes[index].node.as_ref();
            resolution.extend(
                node.unwrap()
                    .unmerged_leaves()
                    .iter()
                    .filter(|resolution_node| !exclusion_list.contains(resolution_node))
                    .map(|&n| NodeIndex::from(n)),
            );
            resolution
        } else {
            // Otherwise we take the resolution of the children
            // Unwrapping here is safe, since parent nodes always have children
            let mut left = self.resolve(treemath::left(index).unwrap(), exclusion_list);
            let right = self.resolve(treemath::right(index, size).unwrap(), exclusion_list);
            // We concatenate the resolution and return it
            left.extend(right);
            left
        }
    }
fn resolve ( & self , index : NodeIndex , exclusion_list : & HashSet < & LeafIndex > ) -> Vec < NodeIndex > { let size = self . leaf_count ( ) ; // We end the recursion at leaf level if self . nodes [ index ] . node_type == NodeType :: Leaf { if self . nodes [ index ] . is_blank ( ) // We can unwrap here, because we just checked that the node is // indeed a leaf. || exclusion_list . contains ( & LeafIndex :: try_from ( index ) . unwrap ( ) ) { return vec ! [ ] ; } else { return vec ! [ index ] ; } } // If a node is not blank, the resolution consists of that node's index, // as well as its unmerged leaves. if ! self . nodes [ index ] . is_blank ( ) { let mut resolution = vec ! [ index ] ; let node = self . nodes [ index ] . node . as_ref ( ) ; resolution . extend ( node . unwrap ( ) . unmerged_leaves ( ) . iter ( ) . filter ( | resolution_node | ! exclusion_list . contains ( resolution_node ) ) . map ( | & n | NodeIndex :: from ( n ) ) , ) ; resolution } else { // Otherwise we take the resolution of the children // Unwrapping here is safe, since parent nodes always have children let mut left = self . resolve ( treemath :: left ( index ) . unwrap ( ) , exclusion_list ) ; let right = self . resolve ( treemath :: right ( index , size ) . unwrap ( ) , exclusion_list ) ; // We concatenate the resolution and return it left . extend ( right ) ; left } }
Compute the resolution for a given node index.
Compute the resolution for a given node index .
&self
index
NodeIndex
exclusion_list
&HashSet<&LeafIndex>
&self
index
NodeIndex
exclusion_list
&HashSet<&LeafIndex>