Version française
Home     About     Download     Resources     Contact us    
Browse thread
Request for weak functional map ...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Stefan Monnier <monnier@i...>
Subject: Re: Request for weak functional map ...
> I wish a data structure similar to the Map provided by standard library
> (logarithmic insertion and deletion) ... but with a "weak key" behavior:

Of course you can implement it in the GC (although it can be tricky if you
data-structure is complex, as you mention).  But another way to do it is to
use a normal non-weak Map but using weak-references for the keys and then
"every once in a while" scan the map to remove entries whose weak-key has
been collected.

If you implement the Map yourself (rather than using the library version),
you can do the weak-key-sweep as part of the normal tree traversal done
during lookups and insertions.


        Stefan