-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashTable.h
More file actions
40 lines (29 loc) · 1005 Bytes
/
HashTable.h
File metadata and controls
40 lines (29 loc) · 1005 Bytes
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
#include <iostream>
#include <list>
#include <string>
class HashTable {
private:
static const int SIZE = 10;
struct Item {
std::string itemName;
std::string itemDescription;
Item* next; // used for collision resolution (separate chaining)
};
// An array of pointers to item structures representing the hash table itself
Item* table[SIZE];
public:
// Default constructor
HashTable();
// Hash function to compute the index for a given key
int HashFunction(std::string key);
// Method to add items to the hash table
void AddItem(std::string itemName, std::string itemDescription); //stores name of people and associates them w their fav drink
// Counts the number of items at a specific index
int countItemsAtIndex(int index);
// Prints all items in the hash table
void PrintTable();
// Prints items stored at a specific index
void PrintItemsInIndex(int index);
// Finds and prints the description of an item given its name
void FindDescription(std::string itemName);
};