def addFront(list, head, val): newNode = Node(val) if head: newNode.next = head list.setHeadNode(newNode) list.recalculateLength() return list.getHeadNode()
def addBack(list, head, val): newNode = Node(val) if not head: list.setHeadNode(newNode) else: while head.next: head = head.next head.next = newNode list.recalculateTail() list.recalculateLength()
def add(self, data): newNode = Node(data) if not self.__tail: self.__head = newNode self.__tail = newNode else: self.__tail.next = newNode self.__tail = newNode self.__length += 1
def createNode(self, val): node = Node() node.setVal(val) return node
def createNode(self, val): node = Node() node.setVal(val) node.setNext(None) return node
def push(self, ele): temp = ListNode() temp.setVal(ele) temp.setNext(self.top) self.top = temp