| @@ 324-341 (lines=18) @@ | ||
| 321 | * |
|
| 322 | * @return mixed the data stored in the node. |
|
| 323 | */ |
|
| 324 | private function deleteEnd() { |
|
| 325 | $prev = $this->head; |
|
| 326 | $current = $this->head; |
|
| 327 | ||
| 328 | while($current !== $this->tail) { |
|
| 329 | $prev = $current; |
|
| 330 | $current = $current->next; |
|
| 331 | } |
|
| 332 | ||
| 333 | $temp = $current; |
|
| 334 | $prev->next = &$this->head; |
|
| 335 | $this->tail = &$prev; |
|
| 336 | $current = null; |
|
| 337 | ||
| 338 | $this->size--; |
|
| 339 | ||
| 340 | return $temp->data; |
|
| 341 | } |
|
| 342 | ||
| 343 | /** |
|
| 344 | * Deletes the first node of the list and returns it. |
|
| @@ 355-373 (lines=19) @@ | ||
| 352 | * |
|
| 353 | * @return mixed the data stored in the node. |
|
| 354 | */ |
|
| 355 | private function deleteEnd() { |
|
| 356 | $prev = $this->head; |
|
| 357 | $current = $this->head; |
|
| 358 | ||
| 359 | while($current !== $this->tail) { |
|
| 360 | $prev = $current; |
|
| 361 | $current = $current->next; |
|
| 362 | } |
|
| 363 | ||
| 364 | $temp = $current; |
|
| 365 | $prev->next = &$this->head; |
|
| 366 | $this->head->prev = &$prev; |
|
| 367 | $this->tail = &$prev; |
|
| 368 | $current = null; |
|
| 369 | ||
| 370 | $this->size--; |
|
| 371 | ||
| 372 | return $temp->data; |
|
| 373 | } |
|
| 374 | ||
| 375 | /** |
|
| 376 | * Deletes the first node of the list and returns it. |
|