Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps (original) (raw)
Mike Skells mike.skells at talk21.com
Wed May 23 07:38:39 UTC 2012
- Previous message: Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps
- Next message: Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Mike,
I have a query, why is this implementation limitted to String? Is this by intent?
in HashMap the patch for hash calculation is 290 final int hash(Object k) { 291 int h = hashMask; 292 if ((0 != h) && (k instanceof String)) { 293 return h ^ ((String)k).hash32(); .... whereas I would have thought that it should be 290 final int hash(Object k) { 291 int h = hashMask; 292 if ((0 != h) && (k instanceof Hash32)) { 293 return h ^ ((Hash32)k).hash32(); ....
As a more flexible improvement could you supply a HashCode and Equals delegate, and then the user can supply either a custom delegate, suitable for that application (e.g.one that iterates through array content, or any other application data structure that needs to be handled differently like c# uses http://msdn.microsoft.com/en-us/library/system.collections.iequalitycomparer )
Regards
Mike
- Previous message: Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps
- Next message: Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]