#include <iostream> #include <map> #include <vector> using namespace std; int main() { vector<int> a,b; int i; for( i = 0; i < 4; ++i ){ a.push_back( i ); } for( i = 5; i > 0; --i ){ b.push_back( i ); } map<string,vector<int> > hash; hash["a"] = a; hash["b"] = b; map<string,vector<int> >::iterator ithash; for( ithash = hash.begin(); ithash != hash.end(); ithash ++){ vector<int>::iterator itvec = (*ithash).second.begin(); while( itvec != (*ithash).second.end() ){ cout << "キー:" << (*ithash).first << " ,データ=" << *itvec << endl; ++itvec; } } return 0; }
できたできた。
/tmp% ./a.out キー:a ,データ=0 キー:a ,データ=1 キー:a ,データ=2 キー:a ,データ=3 キー:b ,データ=5 キー:b ,データ=4 キー:b ,データ=3 キー:b ,データ=2 キー:b ,データ=1
STLがあれななんとかなる気がしてきた。