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
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
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
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()
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
def sll_clear(temp_sll: SinglyLinkedList): temp_sll.clear() return temp_sll
def linkedlist_get(temp_list: SinglyLinkedList, index): return temp_list.get(index)
def sll_remove_obj(temp_list: SinglyLinkedList, element): if temp_list.contains(element): temp_list.remove(element) return temp_list
def linkedlist_print(temp_linkedlist:SinglyLinkedList, id): print("Displaying SinglyLinkedList " + str(id)) temp_linkedlist.display() return
def linkedlist_contains(temp_list: SinglyLinkedList, element): return temp_list.contains(element)
def sll_remove_all(temp_sll: SinglyLinkedList, element): while temp_sll.contains(element): temp_sll.remove(element) return temp_sll