Implemention of HashTable(Part I)

 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;
}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值