45 FakeOne *person1, *person2, *person3;
49 person1 =
new FakeOne(
"Jack Tripper", 654 );
50 person2 =
new FakeOne(
"Richard Kanningam", 456 );
51 person3 =
new FakeOne(
"Dana Scully", 231 );
53 location1 =
new FakeTwo(
"531 Stanford Avenue", 2 );
54 location2 =
new FakeTwo(
"520 Cowper Street", 3 );
77 std::vector<Relation<FakeOne, FakeTwo>*> empty = tab.
getRelByFirst( person1 );
78 std::cout <<
"Querying and empty table the size of the returned vector is " << empty.size()
95 std::vector<Relation<FakeOne, FakeTwo>*>::iterator i;
98 std::vector<Relation<FakeOne, FakeTwo>*> locs = tab.
getRelByFirst( person1 );
100 std::cout << std::endl << person1->
name << std::endl;
101 for ( i = locs.begin(); i != locs.end(); i++ )
103 std::cout <<
"Address: " << ( *i )->getSecond()->address
104 <<
" Floor: " << ( *i )->getSecond()->floor
105 <<
" Date : " << ( *i )->getInfos()[0] << std::endl;
109 std::vector<Relation<FakeOne, FakeTwo>*> pers = tab.
getRelBySecond( location2 );
111 std::cout << std::endl << location2->
address << std::endl;
112 for ( i = pers.begin(); i != pers.end(); i++ )
114 std::cout <<
"Name: " << ( *i )->getFirst()->name
115 <<
" ssn: " << ( *i )->getFirst()->ssn << std::endl;
121 for ( i = locs.begin(); i != locs.end(); i++ ) { tab.
changeSecond( *i, location1 ); }
123 std::cout << std::endl <<
"persion3 location changed" << std::endl;
124 std::cout << std::endl << location2->
address << std::endl;
127 for ( i = pers.begin(); i != pers.end(); i++ )
129 std::cout <<
"Name: " << ( *i )->getFirst()->name
130 <<
" ssn: " << ( *i )->getFirst()->ssn << std::endl;
135 for ( i = locs.begin(); i != locs.end(); i++ ) { tab.
changeFirst( *i, 0 ); }
137 std::cout << std::endl <<
"Jack Tripper set to null" << std::endl;
144 std::cout <<
"Number of relations with location2 = " << pers.size() << std::endl;
146 std::cout << std::endl << location2->
address << std::endl;
147 for ( i = pers.begin(); i != pers.end(); i++ )
149 if ( ( *i )->getFirst() )
150 std::cout <<
"Name: " << ( *i )->getFirst()->name
151 <<
" ssn: " << ( *i )->getFirst()->ssn << std::endl;
157 for ( i = pers.begin(); i != pers.end(); i++ ) { tab.
erase( *i ); }
159 std::cout << std::endl <<
"Removed relations with null pointer" << std::endl;
160 std::cout <<
"Number of relations = " << tab.
size() << std::endl;
161 std::cout << std::endl << location2->
address << std::endl;
164 for ( i = pers.begin(); i != pers.end(); i++ )
166 std::cout <<
"Name: " << ( *i )->getFirst()->name
167 <<
" ssn: " << ( *i )->getFirst()->ssn << std::endl;
170 std::cout << std::endl << person2->
name << std::endl;
175 for ( i = locs.begin(); i != locs.end(); i++ )
177 std::cout <<
"Address: " << ( *i )->getSecond()->address << std::endl;
178 std::cout <<
"Floor: " << ( *i )->getSecond()->floor << std::endl;
179 std::cout <<
"Dates : " << std::endl;
180 for ( index = 0; index < ( *i )->getInfos().size(); index++ )
181 { std::cout << ( *i )->getInfos()[index] << std::endl; }