Hash
来源:互联网 发布:淘宝有什么好吃的水果 编辑:程序博客网 时间:2024/06/05 01:48
void Hash_table::clear()
{
for(int i=0;i<hash_size;i++)
table[i].clear();
}
Error_code Hash_table::insert(const Record &x)
{
int probe=hash(x);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==x)
return duplicate_error;
}
table[probe].insert(0,x);
return success;
}
Error_code Hash_table::retrieve(const Key &target, Record &found) const
{
int probe=hash(target);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==target)
{
found=temp;
return success;
}
}
return not_present;
}
Error_code Hash_table::remove(const Key &target, Record &found)
{
int probe=hash(target);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==target)
{
table[probe].remove(i,found);
return success;
}
return not_present;
}
}
{
for(int i=0;i<hash_size;i++)
table[i].clear();
}
Error_code Hash_table::insert(const Record &x)
{
int probe=hash(x);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==x)
return duplicate_error;
}
table[probe].insert(0,x);
return success;
}
Error_code Hash_table::retrieve(const Key &target, Record &found) const
{
int probe=hash(target);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==target)
{
found=temp;
return success;
}
}
return not_present;
}
Error_code Hash_table::remove(const Key &target, Record &found)
{
int probe=hash(target);
for(int i=0;i<table[probe].size();i++)
{
Record temp;
table[probe].retrieve(i,temp);
if(temp==target)
{
table[probe].remove(i,found);
return success;
}
return not_present;
}
}
0 0
- hash
- Hash
- hash
- hash
- Hash
- hash
- Hash
- HASH
- hash
- hash
- HASH
- hash
- hash
- Hash
- hash
- hash
- Hash...
- hash
- 手把手教你构建自己的Linux系统 —— 软件包下载地址
- unity2D 忽略物体之间的碰撞
- Spiral Matrix II
- TortoiseSVN使用
- LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- Hash
- gcc编译多个文件与makefile应用
- linux 修改错误配置项
- UVa 10763 - Foreign Exchange
- 编写高质量代码——谨防因构造函数抛出异常而引发的问题
- 浅谈free函数的用法
- 计算机科学-第14周模块化程序设计 题目及参考解答
- 电梯算法
- reverse_all_part_words