digitalmars.D - hash function
- Adam D. Ruppe (5/5) Feb 14 2013 druntime has a hash implementation in module rt.util.hash that
- H. S. Teoh (7/12) Feb 14 2013 +1. This is a very good and useful hash function that should be usable
- Zach the Mystic (16/21) Feb 14 2013 This might be a good time to bring up something that was
- Zach the Mystic (4/19) Feb 16 2013 Without objection, so filed...
- Jacob Carlborg (4/8) Feb 14 2013 TypeInfo has a "getHash" method.
- H. S. Teoh (8/16) Feb 15 2013 [...]
- Jacob Carlborg (4/7) Feb 15 2013 Didn't know that. I just knew it existed.
druntime has a hash implementation in module rt.util.hash that looks pretty useful, but isn't publicaly exported by the library anywhere. Does phobos or druntime offer a public hash function like that? If no, can it expose this one?
Feb 14 2013
On Fri, Feb 15, 2013 at 03:26:28AM +0100, Adam D. Ruppe wrote:druntime has a hash implementation in module rt.util.hash that looks pretty useful, but isn't publicaly exported by the library anywhere. Does phobos or druntime offer a public hash function like that? If no, can it expose this one?+1. This is a very good and useful hash function that should be usable by user code. No need to force the user to reinvent the wheel or copy-n-paste code. T -- The diminished 7th chord is the most flexible and fear-instilling chord. Use it often, use it unsparingly, to subdue your listeners into submission!
Feb 14 2013
On Friday, 15 February 2013 at 02:26:31 UTC, Adam D. Ruppe wrote:druntime has a hash implementation in module rt.util.hash that looks pretty useful, but isn't publicaly exported by the library anywhere. Does phobos or druntime offer a public hash function like that? If no, can it expose this one?This might be a good time to bring up something that was bothering me when I examined the current druntime hash implementation. Just out of curiosity I was researching hash functions, and I found the hash function expert Bob Jenkins' FAQ about hashes: http://burtleburtle.net/bob/hash/hashfaq.html He says specifically that any hash function requiring a modulo prime at the end is bad (inefficient), but if I'm not mistaken, the druntime does just that. At line 50 of the associative array module there is a list of primes, and I believe the implementation assumes them to be necessary. https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aaA.d I don't know enough to be sure this is a problem. There might be some other reason for the modulo prime, but I'd like to put my mind at ease on it.
Feb 14 2013
On Friday, 15 February 2013 at 03:33:13 UTC, Zach the Mystic wrote:This might be a good time to bring up something that was bothering me when I examined the current druntime hash implementation. Just out of curiosity I was researching hash functions, and I found the hash function expert Bob Jenkins' FAQ about hashes: http://burtleburtle.net/bob/hash/hashfaq.html He says specifically that any hash function requiring a modulo prime at the end is bad (inefficient), but if I'm not mistaken, the druntime does just that. At line 50 of the associative array module there is a list of primes, and I believe the implementation assumes them to be necessary. https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aaA.d I don't know enough to be sure this is a problem. There might be some other reason for the modulo prime, but I'd like to put my mind at ease on it.Without objection, so filed... http://d.puremagic.com/issues/show_bug.cgi?id=9522
Feb 16 2013
On 2013-02-15 03:26, Adam D. Ruppe wrote:druntime has a hash implementation in module rt.util.hash that looks pretty useful, but isn't publicaly exported by the library anywhere. Does phobos or druntime offer a public hash function like that? If no, can it expose this one?TypeInfo has a "getHash" method. -- /Jacob Carlborg
Feb 14 2013
On Fri, Feb 15, 2013 at 08:28:34AM +0100, Jacob Carlborg wrote:On 2013-02-15 03:26, Adam D. Ruppe wrote:[...] Which has a lot of bugs and inconsistencies. Like the fact that hashing a char[], a const(char)[], and a string (immutable(char)[]) gives different results. T -- Blunt statements really don't have a point.druntime has a hash implementation in module rt.util.hash that looks pretty useful, but isn't publicaly exported by the library anywhere. Does phobos or druntime offer a public hash function like that? If no, can it expose this one?TypeInfo has a "getHash" method.
Feb 15 2013
On 2013-02-15 16:13, H. S. Teoh wrote:Which has a lot of bugs and inconsistencies. Like the fact that hashing a char[], a const(char)[], and a string (immutable(char)[]) gives different results.Didn't know that. I just knew it existed. -- /Jacob Carlborg
Feb 15 2013