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;
}
}