-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashNode.cpp
More file actions
49 lines (41 loc) · 891 Bytes
/
HashNode.cpp
File metadata and controls
49 lines (41 loc) · 891 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
41
42
43
44
45
46
47
48
49
#include "hashMap.hpp"
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
hashNode::hashNode(string s){
keyword = s;
values = new string[100];
valuesSize = 100;
currSize = 0;
srand(time(NULL));
}
hashNode::hashNode(){
keyword = "";
values = new string[100];
valuesSize = 100;
currSize = 0;
srand(time(NULL));
}
hashNode::hashNode(string s, string v){
keyword = s;
values = new string[100];
values[0] = v;
valuesSize = 100;
currSize = 1;
}
void hashNode::addValue(string v) {
values[currSize] = v;
}
void hashNode::dblArray() {
string newValues[valuesSize*2];
for (int i = 0; i < valuesSize; ++i){
newValues[i] = values[i];
}
values = newValues;
}
string hashNode::getRandValue(int check) {
if (check == -1) return "";
if (currSize == 0) return "";
return values[rand()%currSize];
}