Dammit, why didn't I think of strings to one-entry dictionaries? Genius! Alex, that's why you're the judge, and I'm the law.. talking.. guy :) Collecting the empty dictionaries would be a pretty simple job to do on a timer using something similar to your background thread code too.
-J On Wed, May 28, 2008 at 9:01 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > Strings are interned so their reference counting can be tricky and > defeat the weakreference capabilities of Dictionary. I'd just use an Object > if my keys were strings. > > > > There is no efficient mapping of strings to weak object references. You > can map stirngs to a Dictionary of Dictionaries where each sub-dictionary > has one key, but you may still need to collect the empty sub-dictionaries at > some point. > > > > > > > ------------------------------ > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Josh McDonald > *Sent:* Tuesday, May 27, 2008 3:52 PM > *To:* flexcoders@yahoogroups.com > *Subject:* Re: [flexcoders] Dictionary bug > > > > Why do Strings make bad keys in a Dictionary? Is it just because you get no > benefits over an Object but it's slower? > > And If I wanted a map of String (or similar) to a weak reference of an > Object, what's the best way to achieve this? Is the only way to put the > Object as the key in a weakReference Dictionary, and the key Strings as > values in the Dictionary? This would make retrieval pretty slow if the > collection gets sizeable, as you'd have to loop through the Dictionary keys > looking for the value that's your actual key. > > -J > > On Wed, May 28, 2008 at 2:02 AM, Christophe Jolif <[EMAIL PROTECTED]> wrote: > > Alex, > > > > Alex Harui wrote: > > Dictionary keys should be objects. > > That's why I advised him to use Array not Dictionary... > > I must admit I don't know exactly what Daniel wants to do but his method > name > (getItem) reminds me a lot of similar things in Adobe Flex SDK such as > ListBase.itemToItemRenderer method that are exactly doing what I propose. > That's why I suggested him that workaround. But maybe I miss something... > > -- > > Christophe > http://blogs.ilog.com/elixir/author/cjolif > > > > > -- > "Therefore, send not to know For whom the bell tolls. It tolls for thee." > > :: Josh 'G-Funk' McDonald > :: 0437 221 380 :: [EMAIL PROTECTED] > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]