@@ 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 | } |
@@ 210-219 (lines=10) @@ | ||
207 | ||
208 | protected function insertEnd($data) { |
|
209 | $newNode = new SimpleLinkedListNode($data); |
|
210 | if($this->head === null) { |
|
211 | $this->head = &$newNode; |
|
212 | $this->current = &$this->head; |
|
213 | } else { |
|
214 | $current = $this->head; |
|
215 | while($current->next !== null) { |
|
216 | $current = $current->next; |
|
217 | } |
|
218 | $current->next = &$newNode; |
|
219 | } |
|
220 | } |
|
221 | ||
222 | /** |