Deleting the first node

When we remove the first node from a doubly linked list, we just need to make the second node the first node. Set the new first node's previous node to NULL and reduce the total node count, just like the following code:

 

    public function deleteFirst() { 
if ($this->_firstNode !== NULL) {
if ($this->_firstNode->next !== NULL) {
$this->_firstNode = $this->_firstNode->next;
$this->_firstNode->prev = NULL;
} else {
$this->_firstNode = NULL;
}
$this->_totalNode--;
return TRUE;
}
return FALSE;
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset