| @@ 390-407 (lines=18) @@ | ||
| 387 | * |
|
| 388 | * @return mixed the data stored in the node. |
|
| 389 | */ |
|
| 390 | private function deleteEnd() { |
|
| 391 | $prev = $this->head; |
|
| 392 | $current = $this->head; |
|
| 393 | ||
| 394 | while($current !== $this->tail) { |
|
| 395 | $prev = $current; |
|
| 396 | $current = $current->next; |
|
| 397 | } |
|
| 398 | ||
| 399 | $temp = $current; |
|
| 400 | $prev->next = &$this->head; |
|
| 401 | $this->tail = &$prev; |
|
| 402 | $current = null; |
|
| 403 | ||
| 404 | $this->size--; |
|
| 405 | ||
| 406 | return $temp->data; |
|
| 407 | } |
|
| 408 | ||
| 409 | /** |
|
| 410 | * Removes all nodes of the list. It removes from the beginning. |
|
| @@ 411-429 (lines=19) @@ | ||
| 408 | * |
|
| 409 | * @return mixed the data stored in the node. |
|
| 410 | */ |
|
| 411 | private function deleteEnd() { |
|
| 412 | $prev = $this->head; |
|
| 413 | $current = $this->head; |
|
| 414 | ||
| 415 | while($current !== $this->tail) { |
|
| 416 | $prev = $current; |
|
| 417 | $current = $current->next; |
|
| 418 | } |
|
| 419 | ||
| 420 | $temp = $current; |
|
| 421 | $prev->next = &$this->head; |
|
| 422 | $this->head->prev = &$prev; |
|
| 423 | $this->tail = &$prev; |
|
| 424 | $current = null; |
|
| 425 | ||
| 426 | $this->size--; |
|
| 427 | ||
| 428 | return $temp->data; |
|
| 429 | } |
|
| 430 | ||
| 431 | /** |
|
| 432 | * Converts/exports the list content into array type. |
|