-
Notifications
You must be signed in to change notification settings - Fork 0
/
customMap.h
63 lines (47 loc) · 1.18 KB
/
customMap.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* customMap.h
* CustomMap class has implementation of hash table
*
* @authors Olga Kuriatnyk
*/
#ifndef CUSTOMMAP_H
#define CUSTOMMAP_H
#include "customer.h"
#include <cstring>
#include <iostream>
#include <list>
using namespace std;
// hash table
class CustomMap {
public:
// creating an empty table
CustomMap();
// destructor
~CustomMap();
// copy constructor not allowed
CustomMap(const CustomMap &cusMap) = delete;
// move not allowed
CustomMap(CustomMap &&other) = delete;
// assignment not allowed
CustomMap &operator=(const CustomMap &other) = delete;
// move assignment not allowed
CustomMap &operator=(CustomMap &&other) = delete;
// hash function for finding an index based on customerID
int hashFunction(int id);
// get customer object by ID
Customer *getCustomerByID(int id);
// function for adding a customer to the hashtable
void addCustomer(int id, Customer *user);
private:
// structure of list
struct CustomerList {
Customer *obj;
CustomerList *next;
int val;
};
// size of an array
static const int HASH_GROUPS = 29;
// array of lists for hash table
CustomerList *array[HASH_GROUPS] = {};
};
#endif