#include "hash.h"
#include <stdio.h>
int replicate(char key[], unsigned int len, unsigned int len_table)
{
unsigned int return_value = 0;
unsigned int _parameter = 0;
unsigned int step = 0;
unsigned int tem;
unsigned int i = 0;
unsigned int measure = 1;
unsigned int max;
if (len > 4)
{
printf("the len over the max");
}
for (i = 0; i < len; i++)
{
_parameter += key[i] << ((len-1-i)*8);
}
tem = len_table;
while (tem /= 2)
{
measure++;
}
len *= 8;
if ((len) <= measure)
return _parameter;
for (i = 0; i <= (measure-1); i++)
{
step += (1<<i);
}
max = len / measure;
tem = _parameter;
for (i = 0; i <= max; i++)
{
tem >>= (len-measure);
_parameter <<= measure;
_parameter = tem | _parameter;
tem = _parameter;
return_value += _parameter & step;
}
return (return_value % len_table);
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
/* *@parameter key is the value it need to convert *@parameter len is the length of key,but not the size of the array *@parameter len_table is the size of table * * */ int replicate(char key[], unsigned int len, unsigned int len_table);
资源推荐
资源详情
资源评论
收起资源包目录
hash.rar (2个子文件)
hash.h 287B
hash.c 1KB
共 2 条
- 1
资源评论
- pitchwl2013-01-03还行,编译得比较简单
- jy82926722013-05-19可以用,正确
walterCui
- 粉丝: 109
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功