MCPcopy Create free account
hub / github.com/ActiveState/code / insertValue

Method insertValue

recipes/Python/577898_23_Tree/recipe-577898.py:436–447  ·  view source on GitHub ↗

Inserts a new value to tree and keeps it balanced

(self, a)

Source from the content-addressed store, hash-verified

434 return self.__nextSucc(new_node)
435
436 def insertValue(self, a):
437 """ Inserts a new value to tree and keeps it balanced """
438 if self.root is None:
439 self.root = Node(a)
440 elif a is not None:
441 node = self.findNode(a)
442 res = node.contains(a)
443 if res: return res
444 # try to insert a new value into existing node
445 node.insertValue(a)
446 self.__fixNodeInsert(node)
447 return self
448
449 def insertList(self, xs):
450 """ Insert a list of values into a tree """

Callers 1

insertListMethod · 0.95

Calls 5

findNodeMethod · 0.95
__fixNodeInsertMethod · 0.95
NodeClass · 0.70
containsMethod · 0.45
insertValueMethod · 0.45

Tested by

no test coverage detected