-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashMap.h
51 lines (41 loc) · 1.08 KB
/
HashMap.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
#ifndef HASH_MAP
#define HASH_MAP
#include <iostream>
#include <string>
#include "LinkedHashStock.h"
/*
* ETK - April 2022
* HashMap class
* implements hashing with chaining
* where the nodes in the tables are
* LinkedHashStock nodes, which
* contain a pointer to a Stock and a pointer
* to the next entry in the list.
*/
//constants used in generating a hash code
const int HASH_SEED = 5381;
const int HASH_MULTIPLIER = 33;
const int HASH_MASK = unsigned(-1) >> 1;
class HashMap{
public:
// constructor specifies size of table
HashMap(int sz);
~HashMap();
// standard dictionary operations
Stock* find(string key);
bool insert(Stock *e);
bool insert(string n, string t, int q, double p);
void remove(string key);
int size();
// display method for use in debugging
void display();
private:
// utility function
int myHashCode(const string & str);
// data members
// a table of pointers to lists of LinkedHashStock elements
LinkedHashStock **table;
int table_size; // size of table; specified in constructor
int counter; // number of current entries
};
#endif