Re: Weak pointers

From: Kohler Markus (kohlerm@betze.bbn.hp.com)
Date: Tue Mar 18 1997 - 18:08:56 MET


Message-Id: <199703181708.SAA27847@betze.bbn.hp.com>
To: Damien Doligez <Damien.Doligez@inria.fr>
Subject: Re: Weak pointers
In-Reply-To: Damien.Doligez's message of Tue, 18 Mar 1997 17:07:11 +0100.
      <199703181607.RAA13208@tobago.inria.fr>
Date: Tue, 18 Mar 1997 17:08:56 +0000
From: Kohler Markus <kohlerm@betze.bbn.hp.com>

> >But how do you know then that value is not valid anymore ?
>
> What do you mean by "valid" ? It remains valid as long as the GC has
> not deallocated it. And the weak pointer is erased before the value
> is deallocated.
>
> >The same could be done with a "normal" pointer.
>
> A normal pointer will never let the GC deallocate the value.

OK, I think i got the point, as long as you only use the hash table internally
for adding, it's not a problem.

If you use the hashtable to directly access specific nodes, you are running
into trouble. If you want this feature, weak pointers are not usefull.

It depends on what you want to do with your datastructure.

If you "only" use your datastructure as a tree you probably want that only one
node A is deleted if you call delete(A) for example. In this case you just
delete ONE specific pointer to node A.

If you want support operations like "delete all nodes A in the tree", it
really means you have implemented a graph operation.

In this case you have to delete ALL pointers to A.

Regards,
Markus

-- 
+----------------------------------------------------------------------------+
| Markus Kohler                          Hewlett-Packard GmbH                |
| Software Engineer                      Network & System Management Division| 
|                                        IT/E Success Team                   |
+----------------------------------------------------------------------------+



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