55 FakeOne *person1, *person2, *person3;
60 person1 =
new FakeOne(
"Jack Tripper", 654);
61 person2 =
new FakeOne(
"Richard Kanningam", 456);
62 person3 =
new FakeOne(
"Dana Scully", 231);
64 location1 =
new FakeTwo(
"531 Stanford Avenue", 2);
65 location2 =
new FakeTwo(
"520 Cowper Street", 3);
85 std::vector< Relation<FakeOne, FakeTwo>* > empty = tab.
getRelByFirst(person1);
86 std::cout <<
"Querying and empty table the size of the returned vector is "
87 << empty.size() << std::endl;
104 std::vector< Relation<FakeOne, FakeTwo>* >::iterator i;
107 std::vector< Relation<FakeOne, FakeTwo>* > locs = tab.
getRelByFirst(person1);
109 std::cout << std::endl << person1->
name << std::endl;
110 for (i = locs.begin(); i != locs.end(); i++)
112 std::cout <<
"Address: " << (*i)->getSecond()->address
113 <<
" Floor: " << (*i)->getSecond()->floor
114 <<
" Date : " << (*i)->getInfos()[0] << std::endl;
118 std::vector< Relation<FakeOne, FakeTwo>* > pers = tab.
getRelBySecond(location2);
120 std::cout << std::endl << location2->
address << std::endl;
121 for (i = pers.begin(); i != pers.end(); i++)
123 std::cout <<
"Name: " << (*i)->getFirst()->name
124 <<
" ssn: " << (*i)->getFirst()->ssn << std::endl;
132 for (i = locs.begin(); i != locs.end(); i++)
137 std::cout << std::endl <<
"persion3 location changed" << std::endl;
138 std::cout << std::endl << location2->
address << std::endl;
141 for (i = pers.begin(); i != pers.end(); i++)
143 std::cout <<
"Name: " << (*i)->getFirst()->name
144 <<
" ssn: " << (*i)->getFirst()->ssn << std::endl;
151 for (i = locs.begin(); i != locs.end(); i++)
156 std::cout << std::endl <<
"Jack Tripper set to null" << std::endl;
163 std::cout <<
"Number of relations with location2 = " << pers.size() << std::endl;
165 std::cout << std::endl << location2->
address << std::endl;
166 for (i = pers.begin(); i != pers.end(); i++)
168 if ((*i)->getFirst())
169 std::cout <<
"Name: " << (*i)->getFirst()->name
170 <<
" ssn: " << (*i)->getFirst()->ssn << std::endl;
177 for (i = pers.begin(); i != pers.end(); i++)
182 std::cout << std::endl <<
"Removed relations with null pointer" << std::endl;
183 std::cout <<
"Number of relations = " << tab.
size() << std::endl;
184 std::cout << std::endl << location2->
address << std::endl;
187 for (i = pers.begin(); i != pers.end(); i++)
189 std::cout <<
"Name: " << (*i)->getFirst()->name
190 <<
" ssn: " << (*i)->getFirst()->ssn << std::endl;
195 std::cout << std::endl << person2->
name << std::endl;
201 for (i = locs.begin(); i != locs.end(); i++)
203 std::cout <<
"Address: " << (*i)->getSecond()->address << std::endl;
204 std::cout <<
"Floor: " << (*i)->getSecond()->floor << std::endl;
205 std::cout <<
"Dates : " << std::endl;
206 for ( index = 0; index < (*i)->getInfos().size(); index++)
208 std::cout << (*i)->getInfos()[index] << std::endl;