Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 15, 2013 hash function | ||||
---|---|---|---|---|
| ||||
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? |
February 15, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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! |
February 15, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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. |
February 15, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 |
February 15, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Fri, Feb 15, 2013 at 08:28:34AM +0100, Jacob Carlborg wrote: > 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. [...] 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. |
February 15, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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 |
February 16, 2013 Re: hash function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zach the Mystic | 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 |
Copyright © 1999-2021 by the D Language Foundation