DataStructures/Lists/CircularLinkedList.php 1 location
|
@@ 297-310 (lines=14) @@
|
294 |
|
* |
295 |
|
* @return mixed the data stored in the node. |
296 |
|
*/ |
297 |
|
protected function deleteBeginning() { |
298 |
|
// if only there is an element |
299 |
|
if($this->head->next === $this->head) { |
300 |
|
$temp = $this->head; |
301 |
|
$this->head = null; |
302 |
|
return $temp->data; |
303 |
|
} |
304 |
|
|
305 |
|
$temp = $this->head; |
306 |
|
$this->head = &$this->head->next; |
307 |
|
$this->tail->next = &$this->head; |
308 |
|
|
309 |
|
return $temp->data; |
310 |
|
} |
311 |
|
|
312 |
|
/** |
313 |
|
* Deletes at the specified position and returns the data stored. |
DataStructures/Lists/DoublyLinkedList.php 1 location
|
@@ 298-310 (lines=13) @@
|
295 |
|
* |
296 |
|
* @return mixed the data stored in the node. |
297 |
|
*/ |
298 |
|
protected function deleteBeginning() { |
299 |
|
// if only there is an element |
300 |
|
if($this->head->next === $this->head) { |
301 |
|
$temp = $this->head; |
302 |
|
$this->head = null; |
303 |
|
} else { |
304 |
|
$temp = $this->head; |
305 |
|
$this->head = &$this->head->next; |
306 |
|
$this->tail->next = &$this->head; |
307 |
|
|
308 |
|
} |
309 |
|
return $temp->data; |
310 |
|
} |
311 |
|
|
312 |
|
/** |
313 |
|
* Deletes at the specified position and returns the data stored. |