| @@ 343-360 (lines=18) @@ | ||
| 340 | * |
|
| 341 | * @return mixed the data stored in the node. |
|
| 342 | */ |
|
| 343 | private function deleteEnd() { |
|
| 344 | $prev = $this->head; |
|
| 345 | $current = $this->head; |
|
| 346 | ||
| 347 | while($current !== $this->tail) { |
|
| 348 | $prev = $current; |
|
| 349 | $current = $current->next; |
|
| 350 | } |
|
| 351 | ||
| 352 | $temp = $current; |
|
| 353 | $prev->next = &$this->head; |
|
| 354 | $this->tail = &$prev; |
|
| 355 | $current = null; |
|
| 356 | ||
| 357 | $this->size--; |
|
| 358 | ||
| 359 | return $temp->data; |
|
| 360 | } |
|
| 361 | ||
| 362 | /** |
|
| 363 | * Deletes the first node of the list and returns it. |
|
| @@ 360-378 (lines=19) @@ | ||
| 357 | * |
|
| 358 | * @return mixed the data stored in the node. |
|
| 359 | */ |
|
| 360 | private function deleteEnd() { |
|
| 361 | $prev = $this->head; |
|
| 362 | $current = $this->head; |
|
| 363 | ||
| 364 | while($current !== $this->tail) { |
|
| 365 | $prev = $current; |
|
| 366 | $current = $current->next; |
|
| 367 | } |
|
| 368 | ||
| 369 | $temp = $current; |
|
| 370 | $prev->next = &$this->head; |
|
| 371 | $this->head->prev = &$prev; |
|
| 372 | $this->tail = &$prev; |
|
| 373 | $current = null; |
|
| 374 | ||
| 375 | $this->size--; |
|
| 376 | ||
| 377 | return $temp->data; |
|
| 378 | } |
|
| 379 | ||
| 380 | /** |
|
| 381 | * Deletes the first node of the list and returns it. |
|