@@ 299-315 (lines=17) @@ | ||
296 | * |
|
297 | * @return null if the head is null (or list is empty) |
|
298 | */ |
|
299 | public function getAll() { |
|
300 | if($this->head === null) { |
|
301 | return; |
|
302 | } |
|
303 | ||
304 | if($this->head->next === $this->tail) { |
|
305 | yield $this->head->data; |
|
306 | } else { |
|
307 | $current = $this->head; |
|
308 | $i = 0; |
|
309 | while($i < $this->size) { |
|
310 | yield $current->data; |
|
311 | $current = $current->next; |
|
312 | $i++; |
|
313 | } |
|
314 | } |
|
315 | } |
|
316 | ||
317 | /** |
|
318 | * Delete a node in the given position and returns it back. |
@@ 238-254 (lines=17) @@ | ||
235 | * |
|
236 | * @return null if the head is null (or list is empty) |
|
237 | */ |
|
238 | public function getAll() { |
|
239 | if($this->head === null) { |
|
240 | return; |
|
241 | } |
|
242 | ||
243 | if($this->head === $this->tail) { |
|
244 | yield $this->head->data; |
|
245 | } else { |
|
246 | $current = $this->head; |
|
247 | $i = 0; |
|
248 | while($i < $this->size) { |
|
249 | yield $current->data; |
|
250 | $current = $current->next; |
|
251 | $i++; |
|
252 | } |
|
253 | } |
|
254 | } |
|
255 | ||
256 | /** |
|
257 | * Inserts data in the specified position. |