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