On Friday 11 September 2009 10:39:14 Samuel Lebeau wrote:
> Hi,
> I think it's indeed a good feature to discuss for 2.0.
> I've been working on this too and had quite reasonable performance
> when using a hash function that avoids collision.
> The simplest implementation consists in storing array of [key, value]
> tuples indexed by `key.toString()` in a vanilla object.
> i.e. :
>       hash.set(true, value1);
>       hash.set("true", value2);
> is stored as:
>       { "true": [ [true, value1], ["true", value2] ] }
> Custom classes should override their `toString` method to be
> efficiently stored in such a structure, otherwise fetching a value
> would be as slow as a `Array#find` call.
> Having real hashes allows to implement sets too.

Would it be reasonable to to look for a hashcode() method which, if present, 
is used in preference to toString()? In most cases I could write a hashcode 
implementation that runs faster and is more evenly distributed than a human-
readable toString.

Yep, this is Java-esque but that doesn't *always* equal evil!

my wiki ajaxification thing: http://wikizzle.org
my blog: http://jimhigson.blogspot.com/

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to