-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariableHashMap.cpp
More file actions
executable file
·42 lines (32 loc) · 962 Bytes
/
VariableHashMap.cpp
File metadata and controls
executable file
·42 lines (32 loc) · 962 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
#include "VariableHashMap.hpp"
void VariableHashMap::removeWithScope(int s) {
for(int i = 0; i < size; i++) {
if(internalArray[i] != nullptr) {
HashMapNode<VariableName, Variable>* base = new HashMapNode<VariableName, Variable>();
base->setNext(internalArray[i]);
HashMapNode<VariableName, Variable>* node = base;
while(node->getNext() != nullptr) {
if(node->getNext()->getValue()->getScope() == s) {
node->removeNext();
contentsCount--;
} else {
node = node->getNext();
}
}
internalArray[i] = base->getNext();
base->setNext(nullptr);
delete base;
}
}
}
void VariableHashMap::printVariables() {
for(int i = 0; i < size; i++) {
HashMapNode<VariableName, Variable>* node = internalArray[i];
while(node != nullptr) {
node->getValue()->print();
std::cout << " | ";
node = node->getNext();
}
std::cout << std::endl;
}
}