summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorYen-Sheng Ho <ysho@berkeley.edu>2017-04-10 16:21:13 -0700
committerYen-Sheng Ho <ysho@berkeley.edu>2017-04-10 16:21:13 -0700
commit2c443d20de7dc68dbbbee2d5d29fa48b4fbd2619 (patch)
treeec52b774558d178db75a859b1e96b97cadd28425 /src/misc/vec
parent0f1a758c2f2766294b27e6e9f166e792f42b6497 (diff)
parent175b42b48f52852b10af26a59c7e5e7b8e0ee13c (diff)
downloadabc-2c443d20de7dc68dbbbee2d5d29fa48b4fbd2619.tar.gz
abc-2c443d20de7dc68dbbbee2d5d29fa48b4fbd2619.tar.bz2
abc-2c443d20de7dc68dbbbee2d5d29fa48b4fbd2619.zip
merge
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecHsh.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/misc/vec/vecHsh.h b/src/misc/vec/vecHsh.h
index de9a038a..4f15f6f0 100644
--- a/src/misc/vec/vecHsh.h
+++ b/src/misc/vec/vecHsh.h
@@ -140,7 +140,24 @@ static inline int Hsh_IntManEntryNum( Hsh_IntMan_t * p )
SeeAlso []
***********************************************************************/
-static inline int Hsh_IntManHash( unsigned * pData, int nSize, int nTableSize )
+// https://en.wikipedia.org/wiki/Jenkins_hash_function
+static inline int Hsh_IntManHash( unsigned * pData, int nSize, int nTableSize )
+{
+ int i = 0; unsigned hash = 0;
+ unsigned char * pDataC = (unsigned char *)pData;
+ nSize <<= 2;
+ while ( i != nSize )
+ {
+ hash += pDataC[i++];
+ hash += hash << 10;
+ hash ^= hash >> 6;
+ }
+ hash += hash << 3;
+ hash ^= hash >> 11;
+ hash += hash << 15;
+ return (int)(hash % nTableSize);
+}
+static inline int Hsh_IntManHash2( unsigned * pData, int nSize, int nTableSize )
{
static int s_Primes[7] = { 4177, 5147, 5647, 6343, 7103, 7873, 8147 };
unsigned char * pDataC = (unsigned char *)pData;