Re: Weak pointers

From: Wolfgang Lux (
Date: Tue Mar 18 1997 - 18:32:21 MET

Message-Id: <>
To: Kohler Markus <>
Subject: Re: Weak pointers
In-Reply-To: (Your message of Tue, 18 Mar 97 16:37:42 GMT.)
Date: Tue, 18 Mar 97 18:32:21 +0100
From: Wolfgang Lux <>

> > >
> > > IMHO the real solution is to implement a delete method for the tree whcih
> > > takes care of all that internal pointers.
> > >
> >
> > No. The delete method for the tree is the wrong place. You would link
> > your tree implementation hardly with the use of the hash table and
> > disallow the use of the data structure without a hash table or with
> > another hash table implementation. This does not seem good software
> > engineering practice to me.
> >
> That's no problem. In some sense this Tree is not a Tree but some kind of
> directed graph. This graph datastructure could use a hash table and a tree by
> aggregation for example.

> There's n reason why this datastructures has to use a specific hash table.

You are right.

> If one deletes a node in graph this means that ALL references to the node hav
> to be deleted.

But this may no be the thing you want to do! Consider the case where an
element might occur more than once in a tree. If you remove one
reference in the tree you cannot simply call delete because the other
references in the tree might be perfectly valid. But if the last such
reference is removed from the tree you also want to be able to release
the memory of the data structure without regard to the fact that the
element is still referenced from the hash table. In your proposal
either the user would have to make sure that he knows whether (s)he is
removing the last reference from the tree or not and calling a
different function in both cases, or the function which removes an
element from the tree has to count the number of references in the tree
and call delete in that case.

> This also has to do with the finalization mechanism. If a finalize method is
> called when the object is destroyed, the object could tell all it's depends "
> "hey I'm going to be deleted".

OK. But as long as there is a reference to object (and there is one
through the hash table) the object won't be destroyed. The point here
is thatthe status of a reference through the tree is different from
the reference through the hash table pointer. IMHO your proposed data
structure cannot be a simple aggregation of a tree and a hash table
in that case.


Wolfgang Lux                     WZH Heidelberg, IBM Germany
Phone: +49-6221-59-4546                Fax: +49-6221-59-3500
Internet:          Office: mazvm01(lux)

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:09 MET