@@ 373-390 (lines=18) @@ | ||
370 | * |
|
371 | * @return mixed the data stored in the node. |
|
372 | */ |
|
373 | private function deleteEnd() { |
|
374 | $prev = $this->head; |
|
375 | $current = $this->head; |
|
376 | ||
377 | while($current !== $this->tail) { |
|
378 | $prev = $current; |
|
379 | $current = $current->next; |
|
380 | } |
|
381 | ||
382 | $temp = $current; |
|
383 | $prev->next = &$this->head; |
|
384 | $this->tail = &$prev; |
|
385 | $current = null; |
|
386 | ||
387 | $this->size--; |
|
388 | ||
389 | return $temp->data; |
|
390 | } |
|
391 | ||
392 | /** |
|
393 | * Deletes the first node of the list and returns it. |
@@ 399-417 (lines=19) @@ | ||
396 | * |
|
397 | * @return mixed the data stored in the node. |
|
398 | */ |
|
399 | private function deleteEnd() { |
|
400 | $prev = $this->head; |
|
401 | $current = $this->head; |
|
402 | ||
403 | while($current !== $this->tail) { |
|
404 | $prev = $current; |
|
405 | $current = $current->next; |
|
406 | } |
|
407 | ||
408 | $temp = $current; |
|
409 | $prev->next = &$this->head; |
|
410 | $this->head->prev = &$prev; |
|
411 | $this->tail = &$prev; |
|
412 | $current = null; |
|
413 | ||
414 | $this->size--; |
|
415 | ||
416 | return $temp->data; |
|
417 | } |
|
418 | ||
419 | /** |
|
420 | * Deletes the first node of the list and returns it. |