fellowing is some hash function:
/**/
/*
Name: hash functions
Copyright: All Right Reserved @ lizuding@gmail.com
Author: lizuding
Date: 21-01-08 21:46
Description: implemention of hash function
*/
const unsigned long M = 100 ;
/**/ /*
* ELFHash 函数,由于UNIX的“可执行链接格式,ELF”
* const char *key 关键字
*/
int ELFHash( const char * key) ... {
unsigned long h = 0;
while ( *key ) ...{
h = (h << 4) + *key ++;
unsigned long g = h & 0XF0000000L;
if ( g )
h ^= g >> 24;
h &= -g;
}
return h % M;
}
template < class T >
int remainder_hash( int key) ... {
}
/**/ /*
* 移位折叠法
*/
template < class T >
int shift_pucker_hash( int key) ... {
unsigned long tmp = 0;
unsigned long filter = 0X00000033L;
for (int i = 0; i < 16; i += 4) ...{
filter <<= i;
tmp += key & filter;
}
return tmp % M;
}
template < class T >
int divide_pucker_hash( int key) ... {}
template < class T >
int square_media_hash( int key) ... {
unsigned long hash = 0;
hash = key * key;
hash &= 0X0001FF00L;
return hash % 100;
}
Name: hash functions
Copyright: All Right Reserved @ lizuding@gmail.com
Author: lizuding
Date: 21-01-08 21:46
Description: implemention of hash function
*/
const unsigned long M = 100 ;
/**/ /*
* ELFHash 函数,由于UNIX的“可执行链接格式,ELF”
* const char *key 关键字
*/
int ELFHash( const char * key) ... {
unsigned long h = 0;
while ( *key ) ...{
h = (h << 4) + *key ++;
unsigned long g = h & 0XF0000000L;
if ( g )
h ^= g >> 24;
h &= -g;
}
return h % M;
}
template < class T >
int remainder_hash( int key) ... {
}
/**/ /*
* 移位折叠法
*/
template < class T >
int shift_pucker_hash( int key) ... {
unsigned long tmp = 0;
unsigned long filter = 0X00000033L;
for (int i = 0; i < 16; i += 4) ...{
filter <<= i;
tmp += key & filter;
}
return tmp % M;
}
template < class T >
int divide_pucker_hash( int key) ... {}
template < class T >
int square_media_hash( int key) ... {
unsigned long hash = 0;
hash = key * key;
hash &= 0X0001FF00L;
return hash % 100;
}