예제 #1
0
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
    
예제 #2
0
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])
예제 #3
0
def tree_clear(temp_tree: BinarySearchTree):
    temp_tree.makeEmpty()
    return temp_tree
예제 #4
0
def tree_get(temp_tree: BinarySearchTree, key):
    if isinstance(key, tuple):
        return temp_tree.containsKey(key[0])
    else:
        return temp_tree.containsKey(key)
예제 #5
0
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