| @@ 232-248 (lines=17) @@ | ||
| 229 | * | |
| 230 | * @return null if the head is null (or list is empty) | |
| 231 | */ | |
| 232 |     public function getAll() { | |
| 233 |         if($this->head === null) { | |
| 234 | return; | |
| 235 | } | |
| 236 | ||
| 237 |         if($this->head->next === $this->tail) { | |
| 238 | yield $this->head->data; | |
| 239 |         } else { | |
| 240 | $current = $this->head; | |
| 241 | $i = 0; | |
| 242 |             while($i < $this->size) { | |
| 243 | yield $current->data; | |
| 244 | $current = $current->next; | |
| 245 | $i++; | |
| 246 | } | |
| 247 | } | |
| 248 | } | |
| 249 | ||
| 250 | /** | |
| 251 | * Delete a node in the given position and returns it back. | |
| @@ 157-173 (lines=17) @@ | ||
| 154 | * | |
| 155 | * @return null if the head is null (or list is empty) | |
| 156 | */ | |
| 157 |     public function getAll() { | |
| 158 |         if($this->head === null) { | |
| 159 | return; | |
| 160 | } | |
| 161 | ||
| 162 |         if($this->head === $this->tail) { | |
| 163 | yield $this->head->data; | |
| 164 |         } else { | |
| 165 | $current = $this->head; | |
| 166 | $i = 0; | |
| 167 |             while($i < $this->size) { | |
| 168 | yield $current->data; | |
| 169 | $current = $current->next; | |
| 170 | $i++; | |
| 171 | } | |
| 172 | } | |
| 173 | } | |
| 174 | ||
| 175 | /** | |
| 176 | * Inserts data in the specified position. | |