| @@ 308-325 (lines=18) @@ | ||
| 305 | * |
|
| 306 | * @return mixed the data stored in the node. |
|
| 307 | */ |
|
| 308 | private function deleteEnd() { |
|
| 309 | $prev = $this->head; |
|
| 310 | $current = $this->head; |
|
| 311 | ||
| 312 | while($current !== $this->tail) { |
|
| 313 | $prev = $current; |
|
| 314 | $current = $current->next; |
|
| 315 | } |
|
| 316 | ||
| 317 | $temp = $current; |
|
| 318 | $prev->next = &$this->head; |
|
| 319 | $this->tail = &$prev; |
|
| 320 | $current = null; |
|
| 321 | ||
| 322 | $this->size--; |
|
| 323 | ||
| 324 | return $temp->data; |
|
| 325 | } |
|
| 326 | ||
| 327 | /** |
|
| 328 | * Deletes the first node of the list and returns it. |
|
| @@ 333-351 (lines=19) @@ | ||
| 330 | * |
|
| 331 | * @return mixed the data stored in the node. |
|
| 332 | */ |
|
| 333 | private function deleteEnd() { |
|
| 334 | $prev = $this->head; |
|
| 335 | $current = $this->head; |
|
| 336 | ||
| 337 | while($current !== $this->tail) { |
|
| 338 | $prev = $current; |
|
| 339 | $current = $current->next; |
|
| 340 | } |
|
| 341 | ||
| 342 | $temp = $current; |
|
| 343 | $prev->next = &$this->head; |
|
| 344 | $this->head->prev = &$prev; |
|
| 345 | $this->tail = &$prev; |
|
| 346 | $current = null; |
|
| 347 | ||
| 348 | $this->size--; |
|
| 349 | ||
| 350 | return $temp->data; |
|
| 351 | } |
|
| 352 | ||
| 353 | /** |
|
| 354 | * Deletes the first node of the list and returns it. |
|