[Prototype-core] Re: True Hashes using objects as keys

2009-10-06 Thread dabeersk
Here's a use case: I have objects that register themselves as listeners for system notifications. When an object registers, I want to make sure we don't add that object twice. If the listener list is an array, then I have to iterate through the array every time we add a listener, which is

[Prototype-core] Re: True Hashes using objects as keys

2009-09-28 Thread Tim Down
On Sep 11, 4:39 pm, kangax kan...@gmail.com wrote: On Sep 11, 7:08 am, T.J. Crowder t...@crowdersoftware.com wrote: [...] @Jim: Yep, this is Java-esque but that doesn't *always* equal evil! Hardly ever!  I'd say hashCode has a place. Let's step back and ask the question:  What are

[Prototype-core] Re: True Hashes using objects as keys

2009-09-13 Thread artemy tregubenko
On Sun, 13 Sep 2009 01:39:43 +0400, kangax kan...@gmail.com wrote: On Sep 12, 3:05 am, artemy tregubenko m...@arty.name wrote: This may used to unobtrusively store in a hash some data associated with dom nodes. So DOM node would be a key? That doesn't really sound like a good idea. The

[Prototype-core] Re: True Hashes using objects as keys

2009-09-12 Thread artemy tregubenko
This may used to unobtrusively store in a hash some data associated with dom nodes. On Fri, 11 Sep 2009 19:39:04 +0400, kangax kan...@gmail.com wrote: On Sep 11, 7:08 am, T.J. Crowder t...@crowdersoftware.com wrote: [...] @Jim: Yep, this is Java-esque but that doesn't *always* equal

[Prototype-core] Re: True Hashes using objects as keys

2009-09-12 Thread Allen Madsen
Arty, I believe that use case is used by element storage now. Instead of a hash of DOM element to data, you can simply use an array of DOM elements and they will have their storage attached. The speed would probably be faster than a true hash. Allen Madsen http://www.allenmadsen.com On Sat,

[Prototype-core] Re: True Hashes using objects as keys

2009-09-12 Thread kangax
On Sep 12, 3:05 am, artemy tregubenko m...@arty.name wrote: This may used to unobtrusively store in a hash some data associated with   dom nodes. So DOM node would be a key? That doesn't really sound like a good idea. The whole purpose of element storage is to avoid having references to DOM

[Prototype-core] Re: True Hashes using objects as keys

2009-09-11 Thread T.J. Crowder
@Samuel: I've been working on this too and had quite reasonable performance I like it, _should_ perform a *lot* better than a straight array given a reasonable distribution of keys. This is similar to what Java's HashMap does (not that I'm holding it up as a model of high performance). @Jim:

[Prototype-core] Re: True Hashes using objects as keys

2009-09-11 Thread kangax
On Sep 11, 7:08 am, T.J. Crowder t...@crowdersoftware.com wrote: [...] @Jim: Yep, this is Java-esque but that doesn't *always* equal evil! Hardly ever!  I'd say hashCode has a place. Let's step back and ask the question:  What are the use cases for a hash keyed by non-string objects?  

[Prototype-core] Re: True Hashes using objects as keys

2009-09-11 Thread James Aimonetti
My interest was piqued when reading http://www.timdown.co.uk/jshashtable/index.html if that helps further discussion of including the feature. kangax wrote: On Sep 11, 7:08 am, T.J. Crowder t...@crowdersoftware.com wrote: [...] @Jim: Yep, this is Java-esque but that doesn't

[Prototype-core] Re: True Hashes using objects as keys

2009-09-11 Thread Yaffle
May I ask you ? Can I use Hash or vanilla objects for storing [key,value] with key==='constructor' or key==='prototype' ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this

[Prototype-core] Re: True Hashes using objects as keys

2009-09-10 Thread T.J. Crowder
Hi James, You're right, Hash does indeed rely on underlying JavaScript vanilla objects, which can only use strings as keys. Supporting using objects as keys would be a complete rewrite, and a fairly inefficient one in terms of runtime performance (I did it once, and abandoned it as not