Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Weak pointers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kohler Markus <kohlerm@b...>
Subject: Re: Weak pointers
> >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                   |
+----------------------------------------------------------------------------+