-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashLinear.hpp
39 lines (32 loc) · 1.03 KB
/
hashLinear.hpp
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
/**
* Names: Jamie Joung & Taryn Hovenkamp
* Contributions:
* - Live-coded (utilized Live Share via VS Code with audio call)
* - Each function was created with joint efforts, therefore, we understand all of our coding and not just bits and pieces of it.
* - Additionally, each function was commented by both partners and thoroughly discussed
* */
#ifndef HASHLINEAR_HPP
#define HASHLINEAR_HPP
#include <iostream>
#include <string>
using namespace std;
struct node
{
int key;
struct node* next;
};
class HashTable
{
int tableSize; // No. of buckets (linked lists)
node* *table; // Pointer to an array containing buckets
int numOfCollisions = 0;
node* createNode(int key, node* next);
public:
HashTable(int bsize); // Constructor
bool insertItem(int key); // inserts a key into hash table
unsigned int hashFunction(int key); // hash function to map values to key
void printTable();
int getNumOfCollisions();
node* searchItem(int key);
};
#endif