def tree_remove_obj(temp_tree:BinarySearchTree, element): if isinstance(element, tuple): temp_tree.remove(element[0]) else: temp_tree.remove(element) return temp_tree
def p_InputRequiredStruct(p): ''' InputRequiredStruct : Tree Id Assign LP Comparator RP | SArrayList Id Assign LP Comparator Separator Comparator RP ''' if p[1] == 'BinarySearchTree': p[0] = BinarySearchTree(p[5]) generatedStructs[str(p[2])] = ('Tree', p[0]) elif p[1] == 'SortedArrayList': p[0] = SortedArrayList(p[5]) generatedStructs[str(p[2])] = ('SArrayList', p[0])
def tree_clear(temp_tree: BinarySearchTree): temp_tree.makeEmpty() return temp_tree
def tree_get(temp_tree: BinarySearchTree, key): if isinstance(key, tuple): return temp_tree.containsKey(key[0]) else: return temp_tree.containsKey(key)
def tree_no_elements(temp_tree: BinarySearchTree, element): if isinstance(element, tuple): temp_tree.put(element[0], element[1]) else: temp_tree.put(element, None) return temp_tree