@@ 319-336 (lines=18) @@ | ||
316 | * @param integer $index the position. |
|
317 | * @return mixed the data stored in the node. |
|
318 | */ |
|
319 | private function deleteAt($index) { |
|
320 | $i = 0; |
|
321 | $prev = $this->head; |
|
322 | $current = $this->head; |
|
323 | ||
324 | while($i < $index) { |
|
325 | $prev = $current; |
|
326 | $current = $current->next; |
|
327 | $i++; |
|
328 | } |
|
329 | ||
330 | $temp = $current; |
|
331 | $prev->next = &$current->next; |
|
332 | $current = null; |
|
333 | $this->size--; |
|
334 | ||
335 | return $temp->data; |
|
336 | } |
|
337 | ||
338 | /** |
|
339 | * Deletes at the end of the list and returns the data stored. |
@@ 335-353 (lines=19) @@ | ||
332 | * @param integer $index the position. |
|
333 | * @return mixed the data stored in the node. |
|
334 | */ |
|
335 | private function deleteAt($index) { |
|
336 | $i = 0; |
|
337 | $prev = $this->head; |
|
338 | $current = $this->head; |
|
339 | ||
340 | while($i < $index) { |
|
341 | $prev = $current; |
|
342 | $current = $current->next; |
|
343 | $i++; |
|
344 | } |
|
345 | ||
346 | $temp = $current; |
|
347 | $prev->next = &$current->next; |
|
348 | $current->next->prev = &$pre; |
|
349 | $current = null; |
|
350 | $this->size--; |
|
351 | ||
352 | return $temp->data; |
|
353 | } |
|
354 | ||
355 | /** |
|
356 | * Deletes at the end of the list and returns the data stored. |