fn delete(&mut self, item: NodeId) {
        let mut queue = vec![item];
        while let Some(item) = queue.pop() {
            let node = match self.nodes.remove(&item) {
                Some(v) => v,
                None => continue,
            };
            match node.data {
                NodeData::Object { id, items } => {
                    for (_, val) in items {
                        match val {
                            Child::Collection(id) => {
                                queue.push(id);
                            }
                            // do nothing for other values; don't have any subchildren to delete
                            Child::True | Child::False | Child::Null | Child::Int(_) => {}
                        }
                    }
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::String { start, id, .. } => {
                    queue.push(start);
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::StringSegment { next, ids, .. } => {
                    queue.push(next);
                    for (id, _) in ids {
                        self.id_to_node.remove(&id).unwrap();
                    }
                }
                NodeData::Array { start, id, .. } => {
                    queue.push(start);
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::ArraySegment {
                    next,
                    ids,
                    contents,
                    ..
                } => {
                    queue.push(next);
                    for (id, _) in ids {
                        self.id_to_node.remove(&id).unwrap();
                    }
                    for item in contents {
                        match item {
                            Child::Collection(id) => {
                                queue.push(id);
                            }
                            // do nothing for other values; don't have any subchildren to delete
                            Child::True | Child::False | Child::Null | Child::Int(_) => {}
                        }
                    }
                }
            }
        }
    }
/// Deletes a node and all its children. If you want to delete a single segment, try
/// `delete_segment`. This operation is slow since it recurses on all sub-nodes; you may want
/// to consider just moving a node into the tree's `orphan` list.
Deletes a node and all its children. If you want to delete a single segment, try
`delete_segment`. This operation is slow since it recurses on all sub-nodes; you may want
to consider just moving a node into the tree's `orphan` list.
Deletes a node and all its children . If you want to delete a single segment try ` delete_segment ` . This operation is slow since it recurses on all sub - nodes ; you may want to consider just moving a node into the tree ' s ` orphan ` list .
fn delete(&mut self, item: NodeId) {
        let mut queue = vec![item];
        while let Some(item) = queue.pop() {
            let node = match self.nodes.remove(&item) {
                Some(v) => v,
                None => continue,
            };
            match node.data {
                NodeData::Object { id, items } => {
                    for (_, val) in items {
                        match val {
                            Child::Collection(id) => {
                                queue.push(id);
                            }
                            // do nothing for other values; don't have any subchildren to delete
                            Child::True | Child::False | Child::Null | Child::Int(_) => {}
                        }
                    }
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::String { start, id, .. } => {
                    queue.push(start);
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::StringSegment { next, ids, .. } => {
                    queue.push(next);
                    for (id, _) in ids {
                        self.id_to_node.remove(&id).unwrap();
                    }
                }
                NodeData::Array { start, id, .. } => {
                    queue.push(start);
                    self.id_to_node.remove(&id).unwrap();
                }
                NodeData::ArraySegment {
                    next,
                    ids,
                    contents,
                    ..
                } => {
                    queue.push(next);
                    for (id, _) in ids {
                        self.id_to_node.remove(&id).unwrap();
                    }
                    for item in contents {
                        match item {
                            Child::Collection(id) => {
                                queue.push(id);
                            }
                            // do nothing for other values; don't have any subchildren to delete
                            Child::True | Child::False | Child::Null | Child::Int(_) => {}
                        }
                    }
                }
            }
        }
    }
fn delete ( & mut self , item : NodeId ) { let mut queue = vec ! [ item ] ; while let Some ( item ) = queue . pop ( ) { let node = match self . nodes . remove ( & item ) { Some ( v ) => v , None => continue , } ; match node . data { NodeData :: Object { id , items } => { for ( _ , val ) in items { match val { Child :: Collection ( id ) => { queue . push ( id ) ; } // do nothing for other values; don't have any subchildren to delete Child :: True | Child :: False | Child :: Null | Child :: Int ( _ ) => { } } } self . id_to_node . remove ( & id ) . unwrap ( ) ; } NodeData :: String { start , id , .. } => { queue . push ( start ) ; self . id_to_node . remove ( & id ) . unwrap ( ) ; } NodeData :: StringSegment { next , ids , .. } => { queue . push ( next ) ; for ( id , _ ) in ids { self . id_to_node . remove ( & id ) . unwrap ( ) ; } } NodeData :: Array { start , id , .. } => { queue . push ( start ) ; self . id_to_node . remove ( & id ) . unwrap ( ) ; } NodeData :: ArraySegment { next , ids , contents , .. } => { queue . push ( next ) ; for ( id , _ ) in ids { self . id_to_node . remove ( & id ) . unwrap ( ) ; } for item in contents { match item { Child :: Collection ( id ) => { queue . push ( id ) ; } // do nothing for other values; don't have any subchildren to delete Child :: True | Child :: False | Child :: Null | Child :: Int ( _ ) => { } } } } } } }
Deletes a node and all its children.
Deletes a node and all its children .
&mut self
item
NodeId