(k *RBNode[T])
| 255 | } |
| 256 | |
| 257 | func (t *RB[T]) pushFix(k *RBNode[T]) { |
| 258 | for k.parent.color == Red { |
| 259 | if k.parent == k.parent.parent.right { |
| 260 | u := k.parent.parent.left |
| 261 | if u.color == Red { |
| 262 | u.color = Black |
| 263 | k.parent.color = Black |
| 264 | k.parent.parent.color = Red |
| 265 | k = k.parent.parent |
| 266 | } else { |
| 267 | if k == k.parent.left { |
| 268 | k = k.parent |
| 269 | t.rightRotate(k) |
| 270 | } |
| 271 | k.parent.color = Black |
| 272 | k.parent.parent.color = Red |
| 273 | t.leftRotate(k.parent.parent) |
| 274 | } |
| 275 | } else { |
| 276 | u := k.parent.parent.right |
| 277 | if u.color == Red { |
| 278 | u.color = Black |
| 279 | k.parent.color = Black |
| 280 | k.parent.parent.color = Red |
| 281 | k = k.parent.parent |
| 282 | } else { |
| 283 | if k == k.parent.right { |
| 284 | k = k.parent |
| 285 | t.leftRotate(k) |
| 286 | } |
| 287 | k.parent.color = Black |
| 288 | k.parent.parent.color = Red |
| 289 | t.rightRotate(k.parent.parent) |
| 290 | } |
| 291 | } |
| 292 | if k == t.Root { |
| 293 | break |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | t.Root.color = Black |
| 298 | } |
| 299 | |
| 300 | func (t *RB[T]) deleteHelper(node *RBNode[T], key T) bool { |
| 301 | z := t._NIL |
no test coverage detected