| @@ 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 | } |
|
| @@ 237-246 (lines=10) @@ | ||
| 234 | ||
| 235 | protected function insertEnd($data) { |
|
| 236 | $newNode = new SimpleLinkedListNode($data); |
|
| 237 | if($this->head === null) { |
|
| 238 | $this->head = &$newNode; |
|
| 239 | $this->current = &$this->head; |
|
| 240 | } else { |
|
| 241 | $current = $this->head; |
|
| 242 | while($current->next !== null) { |
|
| 243 | $current = $current->next; |
|
| 244 | } |
|
| 245 | $current->next = &$newNode; |
|
| 246 | } |
|
| 247 | } |
|
| 248 | ||
| 249 | protected function insertBeginning($data) { |
|