-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.cpp
67 lines (56 loc) · 1.21 KB
/
Common.cpp
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
#include "Common.h"
#include <iostream>
void ShowHashTable(HashTable* hashTable)
{
std::cout << "Here is Hash table:" << std::endl;
HashNode* current;
for (int i = 0; i < hashTable->HashTableSize; i++)
{
current = hashTable->Data[i];
if (!current)
{
std::cout << "---\n";
continue;
}
if (!current->NextNode)
{
std::cout << "Key: " << current->Key << "\t Value: " << current->Value << std::endl;
continue;
}
while (current)
{
std::cout << "Key: " << current->Key << "\t Value: " << current->Value << " -> ";
current = current->NextNode;
}
std::cout << std::endl;
}
}
void ShowMap(MapHashTable* map)
{
std::cout << "Here is MAP powered by hash table:" << std::endl;
HashNode* current;
for (int i = 0; i < map->Map->HashTableSize; i++)
{
current = map->Map->Data[i];
if (current == nullptr)
{
std::cout << "";
continue;
}
while (current != nullptr)
{
std::cout << "Key: " << current->Key << "\t Value: " << current->Value;
current = current->NextNode;
std::cout << std::endl;
}
}
}
std::string GetKey()
{
std::string key;
std::cout << "Enter key: " << std::endl;
std::cin.clear();
std::cin.ignore(32767, '\n');
getline(std::cin, key);
return key;
}