#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()) //should 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()) //should like this
{
vector<string>::iterator it = iter->second.begin();
while(it != iter->second.end())
{
cout<<(*it++)<<endl;
}
}
return 0;
}