-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (37 loc) · 1.27 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include "hash_table.h"
using std::cout;
using std::endl;
/**
* @brief Created by Fábio Bento - 08/05/2016 @ fabiobento512 github
* A really simple implementation of a hash table using constant or user defined bucket size
*
* Based in the theory of this article: http://www.linuxjournal.com/content/hash-tables—theory-and-practice?page=0,0
*
* This hash table implementation was only for learning purposes, it is not intended for general use,
* use std::unordered_map instead.
*/
int main()
{
try{
hash_table my_hash_table;
my_hash_table.add("ola",1);
my_hash_table.add("xarope",9);
my_hash_table.add("sapo",27);
my_hash_table.add("blabla",1000);
my_hash_table.add("notebook",500);
my_hash_table.add("headphones",1000);
my_hash_table.add("surround",24);
my_hash_table.add("tree",77);
my_hash_table.print_table();
cout << my_hash_table.get("blabla") << endl;
cout << "-----------------------------\n";
my_hash_table.remove("xarope");
my_hash_table.remove("blabla");
my_hash_table.print_table();
}
catch(const std::exception &e){
cout << e.what() << endl;
}
return 0;
}