| @@ 369-386 (lines=18) @@ | ||
| 366 | * |
|
| 367 | * @return mixed the data stored in the node. |
|
| 368 | */ |
|
| 369 | private function deleteEnd() { |
|
| 370 | $prev = $this->head; |
|
| 371 | $current = $this->head; |
|
| 372 | ||
| 373 | while($current !== $this->tail) { |
|
| 374 | $prev = $current; |
|
| 375 | $current = $current->next; |
|
| 376 | } |
|
| 377 | ||
| 378 | $temp = $current; |
|
| 379 | $prev->next = &$this->head; |
|
| 380 | $this->tail = &$prev; |
|
| 381 | $current = null; |
|
| 382 | ||
| 383 | $this->size--; |
|
| 384 | ||
| 385 | return $temp->data; |
|
| 386 | } |
|
| 387 | ||
| 388 | /** |
|
| 389 | * Removes all nodes of the list. It removes from the beginning. |
|
| @@ 389-407 (lines=19) @@ | ||
| 386 | * |
|
| 387 | * @return mixed the data stored in the node. |
|
| 388 | */ |
|
| 389 | private function deleteEnd() { |
|
| 390 | $prev = $this->head; |
|
| 391 | $current = $this->head; |
|
| 392 | ||
| 393 | while($current !== $this->tail) { |
|
| 394 | $prev = $current; |
|
| 395 | $current = $current->next; |
|
| 396 | } |
|
| 397 | ||
| 398 | $temp = $current; |
|
| 399 | $prev->next = &$this->head; |
|
| 400 | $this->head->prev = &$prev; |
|
| 401 | $this->tail = &$prev; |
|
| 402 | $current = null; |
|
| 403 | ||
| 404 | $this->size--; |
|
| 405 | ||
| 406 | return $temp->data; |
|
| 407 | } |
|
| 408 | ||
| 409 | /** |
|
| 410 | * Converts/exports the list content into array type. |
|