(self, data)
| 23 | return self.last |
| 24 | |
| 25 | def addFront(self, data): |
| 26 | |
| 27 | # check if the list is empty |
| 28 | if self.last == None: |
| 29 | return self.addToEmpty(data) |
| 30 | |
| 31 | # allocate memory to the new node and add data to the node |
| 32 | newNode = Node(data) |
| 33 | |
| 34 | # store the address of the current first node in the newNode |
| 35 | newNode.next = self.last.next |
| 36 | |
| 37 | # make newNode as last |
| 38 | self.last.next = newNode |
| 39 | |
| 40 | return self.last |
| 41 | |
| 42 | def addEnd(self, data): |
| 43 | # check if the node is empty |
no test coverage detected