-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
88 lines (71 loc) · 1.92 KB
/
main.cpp
File metadata and controls
88 lines (71 loc) · 1.92 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* This program implements a template linked list as a hashed array. I will use the MD5 algorithm to derive the initial hash value. */
/* Essentially, my code amounts to an array of (very short) linked lists. The idea of hashing is that, once you have derived the record's hash, you are able to access the array position at which it is stored directly. */
/* For hash collision prevention, I've implemented the idea of making each array position the root of a linked list. Thus, for some arbitrary integer, i, roots[i] would be the root of the list containing all elements that hashed to that location. */
#include "ItemType.h"
#include "ListType.cpp"
int main(void)
{
std::cout<<"\n*** Start Routine ***"<<std::endl;
ItemType item;
ListType<ItemType> list;
// HASH_SPACE is 16
item="aaaa";
list.put(item);
item="bbbb";
list.put(item);
item="cccc";
list.put(item);
item="dddd";
list.put(item);
item="eeee";
list.put(item);
item="ffff";
list.put(item);
item="gggg";
list.put(item);
item="hhhh";
list.put(item);
item="iiii";
list.put(item);
item="jjjj";
list.put(item);
item="kkkk";
list.put(item);
item="llll";
list.put(item);
item="mmmm";
list.put(item);
item="nnnn";
list.put(item);
item="oooo";
list.put(item);
item="pppp";
list.put(item);
list.print("part one");
item="gggg";
list.remove(item);
item="kkkk";
list.remove(item);
item="hhhh";
list.remove(item);
item="llll";
list.remove(item);
list.print("part two");
std::cout<<"\n*** End Routine ***"<<std::endl;
std::exit(EXIT_SUCCESS);
}
// Get string from user
/*
ItemType item;
ListType<ItemType> list;
string s;
while(true)
{
std::cout<<"Enter string to hash: ";
std::getline(cin, s);
if(s=="")
break;
item = s;
list.isThere( item );
}
*/