/** * Destroys the data field */ function __destruct() { $this->tag = null; parent::__destruct(); }
/** * Destroys the subfield */ function __destruct() { $this->code = null; $this->data = null; parent::__destruct(); }
/** * Deletes a {@link Structures_LinkedList_DoubleNode} from the list. * * @param Structures_LinkedList_DoubleNode $node Node to delete. * * @return null */ public function deleteNode($node) { /* If this is the root node, and there are more nodes in the list, * make the next node the new root node before deleting this node. */ if ($node === $this->root_node) { $this->root_node = $node->next(); } /* If this is the tail node, and there are more nodes in the list, * make the previous node the tail node before deleting this node */ if ($node === $this->tail_node) { $this->tail_node = $node->previous(); } /* If this is the current node, and there are other nodes in the list, * try making the previous node the current node so that next() works * as expected. * * If that fails, make the next node the current node. * * If that fails, null isn't such a bad place to be. */ if ($node === $this->current) { if ($node->previous()) { $this->current = $node->previous(); } elseif ($node->next()) { $this->current = $node->next(); } else { $this->current = null; } } $node->__destruct(); }