src/lookup3.h(3)
πΈ src/lookup3.h β NAME πΈ
okay so bestie, welcome to src/lookup3.h, which is literally a 32bit hash function implementation. that's it, that's the vibe. π
this whole page is from the torque manual, section 3, and it's giving "auto-generated but make it cute" β we're about to get into it. π
β¨ SYNOPSIS β¨
like, first thing's first, you gotta pull it in:
#include <pbs_config.h>
π¦ Functions
uint32_t hashword (const uint32_t *k, size_t length, uint32_t initval)β this works on all machines. no cap, all of them.uint32_t hashlittle (const void *key, size_t length, uint32_t initval)βhashlittle()-- hash a variable-length key into a 32-bit value.uint32_t hashbig (const void *key, size_t length, uint32_t initval)βhashbig(): This is the same ashashword()on big-endian machines.
π Detailed Description π
32bit hash function implementation.
Taken from: http://burtleburtle.net/bob/hash/
like... it's a hash function library, babes, what more do you want from her π she's been doing this since forever and she's iconic for it.
π Function Documentation π
β uint32_t hashword (const uint32 * k, size_t length, uint32 initval)
This works on all machines. β¨ To be useful, it requires:
- that the key be an array of
uint32's, and - that all your machines have the same endianness, and
- that the length be the number of
uint32's in the key
The function hashword() is identical to hashlittle() on little-endian machines, and identical to hashbig() on big-endian machines, except that the length has to be measured in uint32s rather than in bytes. hashlittle() is more complicated than hashword() only because hashlittle() has to dance around fitting the key bytes into registers. π she's literally doing choreo in there, respect her.
π«Ά Parameters
kβ the key, an array ofuint32valueslengthβ the length of the key, inuint32sinitvalβ the previous hash, or an arbitrary value
π uint32_t hashlittle (const void * key, size_t length, uint32 initval)
hashlittle() -- hash a variable-length key into a 32-bit value. periodt.
π Parameters
keyβ the key (the unaligned variable-length array of bytes)lengthβ the length of the key, counting by bytesinitvalβ can be any 4-byte value
π Returns
Returns a 32-bit value. Every bit of the key affects every bit of the return value. Two keys differing by one or two bits will have totally different hash values. like, one tiny bit flip and she's a whole different person, that's main character energy fr fr π₯
The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do:
h = (h & hashmask(10));
In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (uint8 **)k, do it like this:
for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this code any way you wish, private, educational, or commercial. It's free. π«Ά Bob ate, honestly, king behavior.
Use for hash table lookup, or anything where one collision in 2^^32 is acceptable.
β οΈ Do NOT use for cryptographic purposes. like seriously bestie, do not. she is NOT that kind of girl, this is not a crypto hash, use her for lookup tables only, i'm begging π
π§ uint32_t hashbig (const void * key, size_t length, uint32 initval)
hashbig(): This is the same as hashword() on big-endian machines. It is different from hashlittle() on all machines. hashbig() takes advantage of big-endian byte ordering. big-endian stans stay winning πβ¨
π Author π
Generated automatically by Doxygen for torque from the source code. (so nobody hand-wrote this, it's a robot doing its little robot thing, we still love her π€π)
and that's the whole page, bestie! π¦ this was src/lookup3.h(3) from Version 6.1.3, dated Sat Jan 21 2023 β mwah, go hash something responsibly, ily, bye! π
πΈπ«Ά
π¦ where this page comes from
- epel 9: torque-drmaa-devel 6.1.3-8.el9 Β· OpenPBS and TORQUEv1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms