pub fn remove(mut self) -> V {
            // Ensure that the search stack goes to a leaf. This is necessary to perform deletion
            // in a BTree. Note that this may put the tree in an inconsistent state (further
            // described in leafify's comments), but this is immediately fixed by the
            // removing the value we want to remove
            self.leafify();

            let map = self.map;
            map.length -= 1;

            let mut stack = self.stack;

            // Remove the key-value pair from the leaf that this search stack points to.
            // Then, note if the leaf is underfull, and promptly forget the leaf and its ptr
            // to avoid ownership issues.
            let (value, mut underflow) = unsafe {
                let (_, value) = self.top.from_raw_mut().remove_as_leaf();
                let underflow = self.top.from_raw().node().is_underfull();
                (value, underflow)
            };

            loop {
                match stack.pop() {
                    None => {
                        // We've reached the root, so no matter what, we're done. We manually
                        // access the root via the tree itself to avoid creating any dangling
                        // pointers.
                        if map.root.len() == 0 && !map.root.is_leaf() {
                            // We've emptied out the root, so make its only child the new root.
                            // If it's a leaf, we just let it become empty.
                            map.depth -= 1;
                            map.root.into_edge();
                        }
                        return value;
                    }
                    Some(mut handle) => {
                        if underflow {
                            // Underflow! Handle it!
                            unsafe {
                                handle.from_raw_mut().handle_underflow();
                                underflow = handle.from_raw().node().is_underfull();
                            }
                        } else {
                            // All done!
                            return value;
                        }
                    }
                }
            }
        }
/// Removes the key and value in the top element of the stack, then handles underflows as
/// described in BTree's pop function.
Removes the key and value in the top element of the stack, then handles underflows as
described in BTree's pop function.
Removes the key and value in the top element of the stack then handles underflows as described in BTree ' s pop function .
pub fn remove(mut self) -> V {
            // Ensure that the search stack goes to a leaf. This is necessary to perform deletion
            // in a BTree. Note that this may put the tree in an inconsistent state (further
            // described in leafify's comments), but this is immediately fixed by the
            // removing the value we want to remove
            self.leafify();
            let map = self.map;
            map.length -= 1;
            let mut stack = self.stack;
            // Remove the key-value pair from the leaf that this search stack points to.
            // Then, note if the leaf is underfull, and promptly forget the leaf and its ptr
            // to avoid ownership issues.
            let (value, mut underflow) = unsafe {
                let (_, value) = self.top.from_raw_mut().remove_as_leaf();
                let underflow = self.top.from_raw().node().is_underfull();
                (value, underflow)
            };
            loop {
                match stack.pop() {
                    None => {
                        // We've reached the root, so no matter what, we're done. We manually
                        // access the root via the tree itself to avoid creating any dangling
                        // pointers.
                        if map.root.len() == 0 && !map.root.is_leaf() {
                            // We've emptied out the root, so make its only child the new root.
                            // If it's a leaf, we just let it become empty.
                            map.depth -= 1;
                            map.root.into_edge();
                        }
                        return value;
                    }
                    Some(mut handle) => {
                        if underflow {
                            // Underflow! Handle it!
                            unsafe {
                                handle.from_raw_mut().handle_underflow();
                                underflow = handle.from_raw().node().is_underfull();
                            }
                        } else {
                            // All done!
                            return value;
                        }
                    }
                }
            }
        }
pub fn remove ( mut self ) -> V { // Ensure that the search stack goes to a leaf. This is necessary to perform deletion // in a BTree. Note that this may put the tree in an inconsistent state (further // described in leafify's comments), but this is immediately fixed by the // removing the value we want to remove self . leafify ( ) ; let map = self . map ; map . length -= 1 ; let mut stack = self . stack ; // Remove the key-value pair from the leaf that this search stack points to. // Then, note if the leaf is underfull, and promptly forget the leaf and its ptr // to avoid ownership issues. let ( value , mut underflow ) = unsafe { let ( _ , value ) = self . top . from_raw_mut ( ) . remove_as_leaf ( ) ; let underflow = self . top . from_raw ( ) . node ( ) . is_underfull ( ) ; ( value , underflow ) } ; loop { match stack . pop ( ) { None => { // We've reached the root, so no matter what, we're done. We manually // access the root via the tree itself to avoid creating any dangling // pointers. if map . root . len ( ) == 0 && ! map . root . is_leaf ( ) { // We've emptied out the root, so make its only child the new root. // If it's a leaf, we just let it become empty. map . depth -= 1 ; map . root . into_edge ( ) ; } return value ; } Some ( mut handle ) => { if underflow { // Underflow! Handle it! unsafe { handle . from_raw_mut ( ) . handle_underflow ( ) ; underflow = handle . from_raw ( ) . node ( ) . is_underfull ( ) ; } } else { // All done! return value ; } } } } }
Removes the key and value in the top element of the stack, then handles underflows as
described in BTree's pop function.
Removes the key and value in the top element of the stack then handles underflows as described in BTree ' s pop function .
mut self