Replace the child entry `old` of `id` with `new`, whether it sits in the contiguous child range or among the extra edges. Returns whether an entry changed. Replacing with [`VertexId::DUMMY`] drops the child: every consumer skips dummy entries.
(&mut self, id: VertexId, old: VertexId, new: VertexId)
| 263 | /// Returns whether an entry changed. Replacing with [`VertexId::DUMMY`] |
| 264 | /// drops the child: every consumer skips dummy entries. |
| 265 | pub fn replace_child(&mut self, id: VertexId, old: VertexId, new: VertexId) -> bool { |
| 266 | let (start, count) = { |
| 267 | let vertex = &self.vertices[id.index()]; |
| 268 | (vertex.children, vertex.n_children) |
| 269 | }; |
| 270 | let replaced = self.children[start..start + count] |
| 271 | .iter_mut() |
| 272 | .chain(self.vertices[id.index()].extra.iter_mut()) |
| 273 | .find(|(_, child)| *child == old); |
| 274 | match replaced { |
| 275 | Some(entry) => { |
| 276 | entry.1 = new; |
| 277 | true |
| 278 | } |
| 279 | None => false, |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | pub fn get_vertex_mut(&mut self, id: VertexId) -> Option<&mut AliveVertex> { |
| 284 | self.vertices.get_mut(id.index()) |
no test coverage detected