Removes a value from the tree and keeps it balanced
(self, a)
| 452 | for item in xs: self.insertValue(item) |
| 453 | |
| 454 | def removeValue(self, a): |
| 455 | """ Removes a value from the tree and keeps it balanced """ |
| 456 | node = self.findNode(a) |
| 457 | if not node or not node.contains(a): |
| 458 | return None |
| 459 | # swap the value we want to delete with its inorder successor (always leaf) |
| 460 | succ = self.findInorderSucc(node, a) |
| 461 | self.__swapValues(node, a, succ, succ.values[0]) |
| 462 | # delete leaf node value |
| 463 | succ.removeValue(a) |
| 464 | # fix tree if needed |
| 465 | self.__fixNodeRemove(succ) |
| 466 | return self |
| 467 | |
| 468 | def removeList(self, xs): |
| 469 | """ Deletes a list of values from a tree """ |
no test coverage detected