# Pragma warning (Disable: 4786)
# Include <string>
# Include <iostream>
# Include <algorithm>
# Include <map>
# Include <vector>
Using namespace STD;
Typedef Map <string, string> string2string;
Typedef STD: Map <string, vector <string> string2vector;
Int main ()
{
STD: Map <string, string> map_test;
Map_test.insert (string2string: value_type ("2001", "test1 "));
Map_test.insert (string2string: value_type ("2002", "Test2 "));
Map_test.insert (string2string: value_type ("2003", "test3 "));
Map_test.insert (string2string: value_type ("2004", "test4 "));
Map_test.insert (string2string: value_type ("2005", "test5 "));
Map <string, string >:: const_iterator map_conitor = map_test.begin ();
For (; map_conitor! = Map_test.end (); map_conitor ++)
{
Cout <map_conitor-> first <"" <map_conitor-> second <Endl;
}
Cout <"//////////////////////////////////// /// // n ";
STD: vector <string> vec1;
Vec1.push _ back ("test1_vector1 ");
Vec1.push _ back ("test1_vector2 ");
Vec1.push _ back ("test1_vector3 ");
Vec1.push _ back ("test1_vector4 ");
STD: vector <string> vec2;
Vec2.push _ back ("test2_vector1 ");
Vec2.push _ back ("test2_vector2 ");
Vec2.push _ back ("test2_vector3 ");
Vec2.push _ back ("test2_vector4 ");
STD: Map <string, vector <string> testmap;
Testmap. insert (string2vector: value_type ("10001", vec1 ));
Testmap. insert (string2vector: value_type ("10002", vec2 ));
STD: Map <string, vector <string >:: iterator map_it = testmap. Begin ();
For (; map_it! = Testmap. End (); map_it ++)
{
Cout <map_it-> first <"/t ";
Vector <string >:: iterator mapvec_itor = map_it-> second. Begin ();
For (; mapvec_itor! = Map_it-> second. End (); mapvec_itor ++)
{
Cout <(* mapvec_itor) <"";
}
Cout <Endl;
}
Cout <"/N ////////////////////////////////// /// // "<Endl;
Map <string, vector <string >>:: iterator iter = testmap. Find ("10002 ");
If (ITER! = Testmap. End () // shoshould like this
{
Vector <string >:: iterator it = ITER-> second. Begin ();
While (it! = ITER-> second. End ())
{
Cout <(* It ++) <Endl;
}
}
Return 0;
}
# Pragma warning (Disable: 4786)
# Include <string>
# Include <iostream>
# Include <algorithm>
# Include <map>
# Include <vector>
Using namespace STD;
Typedef Map <string, string> string2string;
Typedef STD: Map <string, vector <string> string2vector;
Int main ()
{
STD: Map <string, string> map_test;
Map_test.insert (string2string: value_type ("2001", "test1 "));
Map_test.insert (string2string: value_type ("2002", "Test2 "));
Map_test.insert (string2string: value_type ("2003", "test3 "));
Map_test.insert (string2string: value_type ("2004", "test4 "));
Map_test.insert (string2string: value_type ("2005", "test5 "));
Map <string, string >:: const_iterator map_conitor = map_test.begin ();
For (; map_conitor! = Map_test.end (); map_conitor ++)
{
Cout <map_conitor-> first <"" <map_conitor-> second <Endl;
}
Cout <"//////////////////////////////////// /// // n ";
STD: vector <string> vec1;
Vec1.push _ back ("test1_vector1 ");
Vec1.push _ back ("test1_vector2 ");
Vec1.push _ back ("test1_vector3 ");
Vec1.push _ back ("test1_vector4 ");
STD: vector <string> vec2;
Vec2.push _ back ("test2_vector1 ");
Vec2.push _ back ("test2_vector2 ");
Vec2.push _ back ("test2_vector3 ");
Vec2.push _ back ("test2_vector4 ");
STD: Map <string, vector <string> testmap;
Testmap. insert (string2vector: value_type ("10001", vec1 ));
Testmap. insert (string2vector: value_type ("10002", vec2 ));
STD: Map <string, vector <string >:: iterator map_it = testmap. Begin ();
For (; map_it! = Testmap. End (); map_it ++)
{
Cout <map_it-> first <"/t ";
Vector <string >:: iterator mapvec_itor = map_it-> second. Begin ();
For (; mapvec_itor! = Map_it-> second. End (); mapvec_itor ++)
{
Cout <(* mapvec_itor) <"";
}
Cout <Endl;
}
Cout <"/N ////////////////////////////////// /// // "<Endl;
Map <string, vector <string >>:: iterator iter = testmap. Find ("10002 ");
If (ITER! = Testmap. End () // shoshould like this
{
Vector <string >:: iterator it = ITER-> second. Begin ();
While (it! = ITER-> second. End ())
{
Cout <(* It ++) <Endl;
}
}
Return 0;
}