| @@ 394-411 (lines=18) @@ | ||
| 391 | * |
|
| 392 | * @return mixed the data stored in the node. |
|
| 393 | */ |
|
| 394 | private function deleteEnd() { |
|
| 395 | $prev = $this->head; |
|
| 396 | $current = $this->head; |
|
| 397 | ||
| 398 | while($current !== $this->tail) { |
|
| 399 | $prev = $current; |
|
| 400 | $current = $current->next; |
|
| 401 | } |
|
| 402 | ||
| 403 | $temp = $current; |
|
| 404 | $prev->next = &$this->head; |
|
| 405 | $this->tail = &$prev; |
|
| 406 | $current = null; |
|
| 407 | ||
| 408 | $this->size--; |
|
| 409 | ||
| 410 | return $temp->data; |
|
| 411 | } |
|
| 412 | ||
| 413 | /** |
|
| 414 | * Deletes the first node of the list and returns it. |
|
| @@ 435-453 (lines=19) @@ | ||
| 432 | * |
|
| 433 | * @return mixed the data stored in the node. |
|
| 434 | */ |
|
| 435 | private function deleteEnd() { |
|
| 436 | $prev = $this->head; |
|
| 437 | $current = $this->head; |
|
| 438 | ||
| 439 | while($current !== $this->tail) { |
|
| 440 | $prev = $current; |
|
| 441 | $current = $current->next; |
|
| 442 | } |
|
| 443 | ||
| 444 | $temp = $current; |
|
| 445 | $prev->next = &$this->head; |
|
| 446 | $this->head->prev = &$prev; |
|
| 447 | $this->tail = &$prev; |
|
| 448 | $current = null; |
|
| 449 | ||
| 450 | $this->size--; |
|
| 451 | ||
| 452 | return $temp->data; |
|
| 453 | } |
|
| 454 | ||
| 455 | /** |
|
| 456 | * Deletes the first node of the list and returns it. |
|