http://www.perl.com/pub/a/2002/08/07/proxyobject.html?page=3

José.

-----Original Message-----
From: christopher j bottaro [mailto:[EMAIL PROTECTED] 
Sent: Saturday, December 20, 2003 8:46 PM
To: [EMAIL PROTECTED]
Subject: deallocating?


just for practice, i made a class BinaryTree.  its just a blessed reference to 
a hash that contains two things:  size and root.  root gets assigned to a 
BinaryTree::Node which is just a bless reference containing: key, value, left, right.

perl deallocates according to reference counts.  so if i want "destory" my tree 
structure, i'd have to make sure there are no references to any of the 
BinaryTree::Node's, right?  something like this...

$my pr_clear;
$pr_clear = sub {
        my $p = shift(); # parent node
        my $w = shift(); # which child of the parent
        my $n = shift(); # child node
        if ($n != undef)        {
                this->$pr_clear($n, "left", $n->left());
                this->$pr_clear($n, "right", $n->right());
                $p->$w(undef);
        }
}

sub clear()     {
        this->$pr_clear(this->{root}, "left", this->{root}->left());
        this->$pr_clear(this->{root}, "right", this->{root}->right());
        this->{root} = undef;
}

thanks in advance, and thanks to those who helped with the module questions,
-- christopher

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> 
<http://learn.perl.org/first-response>




**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to