-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensitiveHash.h
More file actions
70 lines (55 loc) · 1.79 KB
/
SensitiveHash.h
File metadata and controls
70 lines (55 loc) · 1.79 KB
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
64
65
66
67
68
69
70
/*
* SensitiveHash.h
* Daniel Jarka & Paul Wang
* 12/10/24
*
* CS 15 Project 4: Gerp
*
* SensitiveHash is a class that represents a HashMap that contains buckets
* for the different cases of a particular word. For example, the word all
* variations of "keep," such as "KEEP" "Keep" or "KEep" will be sent to this
* SensitiveHash class. From there, each case variation is mapped to a unique
* bucket. SensitiveHash also defines a "line_loc" struct which is used to
* store the original word of a key (since all of our keys are first converted
* to lowercase), the line number a key appears on, and the file number a key
* appears in. This struct is used for mapping and accessing. The table of
* SensitiveHash is a pointer to "sensitive Bucket" structs, which contain
* the key of the bucket, an isEmpty boolean, and a line_loc vector that
* represents the "value" of a key. This value is all the line locations
* that the word appears on.
*/
#ifndef REFERENCE_SENSITIVEHASH_H
#define REFERENCE_SENSITIVEHASH_H
#include <string>
#include <iostream>
#include <vector>
#include <functional>
#include <utility>
#include <cctype>
class SensitiveHash {
public:
struct line_loc {
int line_num;
int file_num;
std::string original_name;
};
struct sensitiveBucket {
std::string key;
bool isEmpty = true;
std::vector<line_loc> value;
};
SensitiveHash();
~SensitiveHash();
void insert(line_loc lines);
std::vector<SensitiveHash::line_loc> findKey(std::string key);
SensitiveHash::sensitiveBucket* getTable();
int getCapacity();
bool contains(std::string key);
private:
sensitiveBucket* table;
int capacity;
int numItems;
const double load_factor = 0.7;
void expand();
};
#endif