(self, data)
| 40 | return self.last |
| 41 | |
| 42 | def addEnd(self, data): |
| 43 | # check if the node is empty |
| 44 | if self.last == None: |
| 45 | return self.addToEmpty(data) |
| 46 | |
| 47 | # allocate memory to the new node and add data to the node |
| 48 | newNode = Node(data) |
| 49 | |
| 50 | # store the address of the last node to next of newNode |
| 51 | newNode.next = self.last.next |
| 52 | |
| 53 | # point the current last node to the newNode |
| 54 | self.last.next = newNode |
| 55 | |
| 56 | # make newNode as the last node |
| 57 | self.last = newNode |
| 58 | |
| 59 | return self.last |
| 60 | |
| 61 | def addAfter(self, data, item): |
| 62 |
no test coverage detected