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