Пример #1
0
def map_print(temp_map:Map, id):
    keys = temp_map.getKeys()
    values = temp_map.getValues()
    print("Displaying Map " + str(id))
    for i in range(0, keys.size()):
        key = keys.get(i)
        value = values.get(i)
        print(str(key) + ', '+ str(value))
    return
def map_remove_all(temp_map: Map, element):
    if isinstance(element, tuple):
        while temp_map.get(element[0]):
            temp_map.remove(element[0])
    else:
        while temp_map.get(element):
            temp_map.remove(element)
    return temp_map
Пример #3
0
def p_Structures(p):
    ''' Structures : DLQ
                    | Map
                    | AL
                    | CDLL
                    | AS
                    | Set
                    | Bag
    '''
    if p[1] == 'Map':  # El value del Token
        p[0] = Map()
    elif p[1] == 'CircularDoublyLinkedList':
        p[0] = CircularDoublyLinkedList()
    elif p[1] == 'Set':
        p[0] = ArraySet()
    elif p[1] == 'Bag':
        p[0] = DynamicBag()
    elif p[1] == 'ArrayStack':
        p[0] = Stack()
    elif p[1] == 'DoublyLinkedQueue':
        p[0] = DoublyLinkedQueue()
Пример #4
0
def map_clear(temp_map: Map):
    temp_map.makeEmpty()
    return temp_map
Пример #5
0
def map_get(temp_map: Map, key):
    if isinstance(key, tuple):
        return temp_map.containsKey(key[0])
    else:
        return temp_map.containsKey(key)
Пример #6
0
def map_remove_obj(temp_map: Map, element):
    temp_map.remove(element)
    return temp_map
Пример #7
0
def map_no_elements(temp_map: Map, element):
    if isinstance(element, tuple):
        temp_map.put(element[0], element[1])
    else:
        temp_map.put(element, None)
    return temp_map