@@ 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 | } |
@@ 218-227 (lines=10) @@ | ||
215 | ||
216 | protected function insertEnd($data) { |
|
217 | $newNode = new SimpleLinkedListNode($data); |
|
218 | if($this->head === null) { |
|
219 | $this->head = &$newNode; |
|
220 | $this->current = &$this->head; |
|
221 | } else { |
|
222 | $current = $this->head; |
|
223 | while($current->next !== null) { |
|
224 | $current = $current->next; |
|
225 | } |
|
226 | $current->next = &$newNode; |
|
227 | } |
|
228 | } |
|
229 | ||
230 | /** |