chaining.cpp File Reference

Implementation of hash chains. More...

`#include <cmath>`
`#include <iostream>`
`#include <memory>`
`#include <vector>`
Include dependency graph for chaining.cpp:

## Classes

class | hash_chain
| Chain class with a given modulus. More...

## Functions

int | main ()

## Detailed Description

Implementation of hash chains.

Author
  vasutomar
  Krishna Vedala

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function

Returns
  `0` always

{
int c = 0, x = 0, mod = 0, h = 0;
std::cout << "Enter the size of Hash Table. = ";
std::cin >> mod;
hash_chain mychain(mod);
bool loop = true;
while (loop) {
std::cout << std::endl;
std::cout << "PLEASE CHOOSE -" << std::endl;
std::cout << "1. Add element." << std::endl;
std::cout << "2. Find element." << std::endl;
std::cout << "3. Generate Hash." << std::endl;
std::cout << "4. Display Hash table." << std::endl;
std::cout << "5. Exit." << std::endl;
std::cin >> c;
switch (c) {
case 1:
std::cout << "Enter element to add = ";
std::cin >> x;
h = mychain.hash(x);
h = std::abs(h);
mychain.add(x, h);
break;
case 2:
std::cout << "Enter element to search = ";
std::cin >> x;
h = mychain.hash(x);
mychain.find(x, h);
break;
case 3:
std::cout << "Enter element to generate hash = ";
std::cin >> x;
std::cout << "Hash of " << x << " is = " << mychain.hash(x);
break;
case 4:
mychain.display();
break;
default:
loop = false;
break;
}
std::cout << std::endl;
}
/*add(1,&head1);
add(2,&head1);
add(3,&head2);
add(5,&head1);
display(&head1);
display(&head2);*/
return 0;
}
std::cin
std::cout
hash_chain
Chain class with a given modulus.
Definition: chaining.cpp:16
std::endl
T endl(T... args)
h
int h(int key)
Definition: hash_search.cpp:45
Here is the call graph for this function: