| @@ 87-94 (lines=8) @@ | ||
| 84 | } | |
| 85 | ||
| 86 | $newNode = new Node($data); | |
| 87 |         if($this->head === null) { | |
| 88 | $this->head = &$newNode; | |
| 89 | $newNode->next = null; | |
| 90 |         } else { | |
| 91 | $temp = $this->head; | |
| 92 | $this->head = &$newNode; | |
| 93 | $newNode->next = &$temp; | |
| 94 | } | |
| 95 | ||
| 96 | $this->size++; | |
| 97 | } | |
| @@ 211-220 (lines=10) @@ | ||
| 208 | ||
| 209 |     protected function insertEnd($data) { | |
| 210 | $newNode = new SinglyLinkedListNode($data); | |
| 211 |         if($this->head === null) { | |
| 212 | $this->head = &$newNode; | |
| 213 | $this->current = &$this->head; | |
| 214 |         } else { | |
| 215 | $current = $this->head; | |
| 216 |             while($current->next !== null) { | |
| 217 | $current = $current->next; | |
| 218 | } | |
| 219 | $current->next = &$newNode; | |
| 220 | } | |
| 221 | } | |
| 222 | ||
| 223 | /** | |