Repository navigation
Expand file tree
/
Copy pathentry.cpp
More file actions
97 lines (85 loc) · 2.47 KB
/
Copy pathentry.cpp
File metadata and controls
97 lines (85 loc) · 2.47 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
89
90
91
92
93
94
95
96
97
#include "entry.hpp"
Entry::Entry(){
id = "None"; //default value for not initialized id
page_title = "None"; //dedefault value for not initialized page_tiyle
conn_tree = new ConnectionTree();
}
//constructor for entries
//assignes values given
Entry::Entry(std::string new_page_title, std::string new_id){
id = new_id;
page_title = new_page_title;
loc = -1;
clique = new Clique();
clique->push(this);
specs = NULL;
//generating hashvalue for entry
hashvalue = hash_value_calculator(new_page_title, new_id);
conn_tree = new ConnectionTree();
}
Entry::Entry(std::string new_page_title, std::string new_id, Parserlist* list){
id = new_id;
page_title = new_page_title;
loc = -1;
clique = new Clique();
clique->push(this);
specs = list;
//generating hashvalue for entry
hashvalue = hash_value_calculator(new_page_title, new_id);
conn_tree = new ConnectionTree();
}
//entry destructor
Entry::~Entry(){
Clique* cp;
if(clique != NULL) {
cp = clique;
clique->update_clique_ptrs(NULL);
int size = cp->size;
for(int i=0 ; i < size ; i++) {
delete cp->pop();
}
delete cp;
}
if(specs != NULL)
delete specs;
if(conn_tree != NULL)
delete conn_tree;
}
//id getter
std::string Entry::get_id(){
return id;
}
//page title getter
std::string Entry::get_page_title(){
return page_title;
}
Parserlist* Entry::get_specs() {
return specs;
}
//hashvalue getter
unsigned long long Entry::get_hashvalue(){
return hashvalue;
}
//debug function prints entry strings
void Entry::print(){
std::cout << page_title << "//" << id << std::endl;
}
//merges the clique of this entry with the given entry's clique
void Entry::merge(Entry *e){
if(e->clique != clique){
// e->clique->replace_different(this->clique);
// e->clique->replace_different(this->clique);
clique->merge_different(e->clique);
clique->merge(e->clique); //call clique merrge
clique->update_clique_ptrs(clique); //make all entries in the clique point to this new merged one
}
}
//pushes given entry's clique to different list and vice versa
void Entry::differs_from(Entry *e) {
if( !e->clique->different->find(clique) ) {
e->clique->different->push(clique);
}
if( !clique->different->find(e->clique) ) {
clique->different->push(e->clique);
}
}