Update the critical key after removing the front entry of the leaf node.
(&mut self, pool: &mut NodePool<F>)
| 406 | |
| 407 | /// Update the critical key after removing the front entry of the leaf node. |
| 408 | fn update_crit_key(&mut self, pool: &mut NodePool<F>) { |
| 409 | // Find the inner level containing the critical key for the current leaf node. |
| 410 | let crit_level = match self.left_sibling_branch_level(self.size - 1) { |
| 411 | None => return, |
| 412 | Some(l) => l, |
| 413 | }; |
| 414 | let crit_kidx = self.entry[crit_level] - 1; |
| 415 | |
| 416 | // Extract the new critical key from the leaf node. |
| 417 | let crit_key = pool[self.leaf_node()].leaf_crit_key(); |
| 418 | let crit_node = self.node[crit_level]; |
| 419 | |
| 420 | match pool[crit_node] { |
| 421 | NodeData::Inner { |
| 422 | size, ref mut keys, .. |
| 423 | } => { |
| 424 | debug_assert!(crit_kidx < size); |
| 425 | keys[usize::from(crit_kidx)] = crit_key; |
| 426 | } |
| 427 | _ => panic!("Expected inner node"), |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | /// Given that the current leaf node is in an unhealthy (underflowed or even empty) status, |
| 432 | /// balance it with sibling nodes. |
no test coverage detected