cvs: pear /Structures_LinkedList CHANGELOG Double.php Single.php

From: Date: Sat, 14 Oct 2006 16:39:41 +0000
Subject: cvs: pear /Structures_LinkedList CHANGELOG Double.php Single.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42560@lists.php.net to get a copy of this message
dbs Sat Oct 14 16:39:41 2006 UTC Modified files: /pear/Structures_LinkedList CHANGELOG Single.php Double.php Log: Add destructors to remove references to unecessary objects http://cvs.php.net/viewvc.cgi/pear/Structures_LinkedList/CHANGELOG?r1=1.1&r2=1.2&diff_format=u Index: pear/Structures_LinkedList/CHANGELOG diff -u pear/Structures_LinkedList/CHANGELOG:1.1 pear/Structures_LinkedList/CHANGELOG:1.2 --- pear/Structures_LinkedList/CHANGELOG:1.1 Wed Oct 11 03:24:34 2006 +++ pear/Structures_LinkedList/CHANGELOG Sat Oct 14 16:39:40 2006 @@ -1,3 +1,12 @@ +0.0.8 +* Add destructors to avoid holding onto way too much memory + +0.0.7 +* Correct examples +* Convert to PEAR_Exception for error handling + +0.0.6 + 0.0.5 * Create a singly linked list (Structures_LinkedList_Single) * Refactor Structures_LinkedList_Double to extend _Single http://cvs.php.net/viewvc.cgi/pear/Structures_LinkedList/Single.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Structures_LinkedList/Single.php diff -u pear/Structures_LinkedList/Single.php:1.1 pear/Structures_LinkedList/Single.php:1.2 --- pear/Structures_LinkedList/Single.php:1.1 Wed Oct 11 03:24:34 2006 +++ pear/Structures_LinkedList/Single.php Sat Oct 14 16:39:40 2006 @@ -48,7 +48,7 @@ * @author Dan Scott <dscott@laurentian.ca> * @copyright 2006 Dan Scott * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 - * @version CVS: $Id: Single.php,v 1.1 2006/10/11 03:24:34 dbs Exp $ + * @version CVS: $Id: Single.php,v 1.2 2006/10/14 16:39:40 dbs Exp $ * @link http://pear.php.net/package/Structures_LinkedList_Single * @example single_link_example.php * @@ -111,6 +111,36 @@ } // }}} + // {{{ Destructor: function __destruct() + /** + * Structures_LinkedList_Single destructor + * + * If we do not destroy all of the references in the linked list, + * we will quickly run out of memory for large / complex structures. + * + * @param Structures_LinkedList_SingleNode $root root node for the + * linked list + */ + function __destruct() + { + /* + * Starting with root node, set last node = root_node + * get next node + * if next node exists, delete last node reference to next + */ + if (!$last_node = $this->root_node) { + return; + } + while ($next_node = $last_node->next()) { + $last_node->setNext(null); + } + $this->current = null; + $this->root_node = null; + $last_node = null; + $next_node = null; + } + // }}} + // {{{ function current() /** * Returns the current node in the linked list http://cvs.php.net/viewvc.cgi/pear/Structures_LinkedList/Double.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Structures_LinkedList/Double.php diff -u pear/Structures_LinkedList/Double.php:1.1 pear/Structures_LinkedList/Double.php:1.2 --- pear/Structures_LinkedList/Double.php:1.1 Wed Oct 11 03:24:34 2006 +++ pear/Structures_LinkedList/Double.php Sat Oct 14 16:39:40 2006 @@ -48,7 +48,7 @@ * @author Dan Scott <dscott@laurentian.ca> * @copyright 2006 Dan Scott * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 - * @version CVS: $Id: Double.php,v 1.1 2006/10/11 03:24:34 dbs Exp $ + * @version CVS: $Id: Double.php,v 1.2 2006/10/14 16:39:40 dbs Exp $ * @link http://pear.php.net/package/Structures_LinkedList_Single * @example double_link_example.php * @@ -96,6 +96,38 @@ } // }}} + // {{{ Destructor: function __destruct() + /** + * Structures_LinkedList_Single destructor + * + * If we do not destroy all of the references in the linked list, + * we will quickly run out of memory for large / complex structures. + * + * @param Structures_LinkedList_SingleNode $root root node for the + * linked list + */ + function __destruct() + { + /* + * Starting with root node, set last node = root_node + * get next node + * if next node exists, delete last node reference to next + */ + if (!$last_node = $this->root_node) { + return; + } + while ($next_node = $last_node->next()) { + $last_node->setNext(null); + $last_node->setPrevious(null); + } + $this->current = null; + $this->root_node = null; + $this->tail_node = null; + $last_node = null; + $next_node = null; + } + // }}} + // {{{ function end() /** * Sets the pointer for the linked list to its last node

« previous php.pear.cvs (#42560) next »