def insertNode(self, afterNode, newData): newNode = Node(newData) if afterNode is None: return nextNode = afterNode.next afterNode.next = newNode newNode.next = nextNode self.size += 1
def insertHead(self, newData): newNode = Node(newData) if self.head is None: self.head = newNode self.size += 1 return newNode.next = self.head self.head = newNode