Simple_Hash:
#pragma once
class Simple_Hash
{
int* data;
int count;
int capacity=10000;
public:
Simple_Hash()
{
data = new int[capacity]();
count = 0;
}
void insert(int key, int val)
{
data[key] = val;
count++;
}
void remove(int key)
{
data[key] = 0;
count--;
}
int search(int key)
{
return data[key];
}
~Simple_Hash()
{
delete[] data;
}
};
Hash:
#pragma once
#include <iostream>
class Hash
{
int* data;
int count;
int length;
public:
Hash(int length) :length(length)
{
data = new int[length]();
count = 0;
}
~Hash()
{
delete[] data;
}
bool insert(int key)
{
if (full())
{
return false;
}
int base = key % length;
int step=0;
int i = base;
while (data[i] != 0)
{
if (data[i] == key)
{
return false;
}
step++;
i = (base + step) % length;
}
data[i] = key;
count++;
return true;
}
bool full()
{
return count >= length - 1;
}
int size()
{
return count;
}
bool empty()
{
return count == 0;
}
int search(int key)
{
int base = key % length;
int step = 0;
int i = base;
while (true)
{
if