Exemplo n.º 1
0
 def getValues(self):
     result = SinglyLinkedList()
     # the result will be a list with all the values
     for element in self.buckets:
         if element is not None and element.isStatus() is True:
             result.add(element.getValue())
     return result
Exemplo n.º 2
0
 def getValues(self):
     # The method returns a list with all the values
     result = SinglyLinkedList()
     for lists in self.buckets:
         if lists is not None:
             tempIndex = 0
             while tempIndex < lists.size():
                 element = lists.get(tempIndex)
                 if element is not None and element.isStatus() is True:
                     result.add(element.getValue())
                 tempIndex += 1
     return result
Exemplo n.º 3
0
 def __init__(self,
              keyComparator: Comparator = None,
              valueComparator: Comparator = None,
              size: int = 10):
     self.buckets = [None] * size
     firstTempIndex: int = 0
     while firstTempIndex < size:
         self.buckets[firstTempIndex] = SinglyLinkedList()
         firstTempIndex += 1
     self.currentSize = 0
     self.keyComparator = keyComparator
     self.valueComparator = valueComparator
Exemplo n.º 4
0
def p_Structures(p):
    ''' Structures : DLQ
                    | Map
                    | AL
                    | CDLL
                    | AS
                    | Set
                    | Bag
                    | SLL
    '''
    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()
    elif p[1] == 'SinglyLinkedList':
        p[0] = SinglyLinkedList()
Exemplo n.º 5
0
 def makeEmpty(self):
     tempIndex: int = 0
     while tempIndex < len(self.buckets):
         self.buckets[tempIndex] = SinglyLinkedList()
         tempIndex += 1
     self.currentSize = 0
 def getValues(self):
     result = SinglyLinkedList()
     self.getValuesAux(self.root, result)
     return result
Exemplo n.º 7
0
def sll_clear(temp_sll: SinglyLinkedList):
    temp_sll.clear()
    return temp_sll
Exemplo n.º 8
0
def linkedlist_get(temp_list: SinglyLinkedList, index):
    return temp_list.get(index)
Exemplo n.º 9
0
def sll_remove_obj(temp_list: SinglyLinkedList, element):
    if temp_list.contains(element):
        temp_list.remove(element)
    return temp_list
Exemplo n.º 10
0
def linkedlist_print(temp_linkedlist:SinglyLinkedList, id):
    print("Displaying SinglyLinkedList " + str(id))
    temp_linkedlist.display()
    return
Exemplo n.º 11
0
def linkedlist_contains(temp_list: SinglyLinkedList, element):
    return temp_list.contains(element)
Exemplo n.º 12
0
def sll_remove_all(temp_sll: SinglyLinkedList, element):
    while temp_sll.contains(element):
        temp_sll.remove(element)
    return temp_sll