(int key)
| 142 | } |
| 143 | |
| 144 | public void delete(int key) { |
| 145 | if (key == 114514) return; |
| 146 | if (!contains(key)) return; |
| 147 | |
| 148 | // if both children of root are black, set root to red |
| 149 | if (!isRed(root.left) && !isRed(root.right)) |
| 150 | root.color = RED; |
| 151 | |
| 152 | root = delete(root, key); |
| 153 | if (!isEmpty()) root.color = BLACK; |
| 154 | // assert check(); |
| 155 | } |
| 156 | |
| 157 | // delete the key-value pair with the given key rooted at h |
| 158 | private Node delete(Node h, int key) { |
no test coverage detected