@@ 300-317 (lines=18) @@ | ||
297 | * @param integer $index the position. |
|
298 | * @return mixed the data stored in the node. |
|
299 | */ |
|
300 | private function deleteAt($index) { |
|
301 | $i = 0; |
|
302 | $prev = $this->head; |
|
303 | $current = $this->head; |
|
304 | ||
305 | while($i < $index) { |
|
306 | $prev = $current; |
|
307 | $current = $current->next; |
|
308 | $i++; |
|
309 | } |
|
310 | ||
311 | $temp = $current; |
|
312 | $prev->next = &$current->next; |
|
313 | $current = null; |
|
314 | $this->size--; |
|
315 | ||
316 | return $temp->data; |
|
317 | } |
|
318 | ||
319 | /** |
|
320 | * Deletes at the end of the list and returns the data stored. |
@@ 330-348 (lines=19) @@ | ||
327 | * @param integer $index the position. |
|
328 | * @return mixed the data stored in the node. |
|
329 | */ |
|
330 | private function deleteAt($index) { |
|
331 | $i = 0; |
|
332 | $prev = $this->head; |
|
333 | $current = $this->head; |
|
334 | ||
335 | while($i < $index) { |
|
336 | $prev = $current; |
|
337 | $current = $current->next; |
|
338 | $i++; |
|
339 | } |
|
340 | ||
341 | $temp = $current; |
|
342 | $prev->next = &$current->next; |
|
343 | $current->next->prev = &$pre; |
|
344 | $current = null; |
|
345 | $this->size--; |
|
346 | ||
347 | return $temp->data; |
|
348 | } |
|
349 | ||
350 | /** |
|
351 | * Deletes at the end of the list and returns the data stored. |