// Arun Saha, 2010-Oct-19
// http://stackoverflow.com/questions/3970395/populate-c-maps-content-in-a-loop-scope
#include <set>
#include <map>
#include <iostream>
using std::cout;
typedef std::set< int > IntSet;
typedef std::map< int, IntSet > MapOfIntSet;
void print( IntSet const & );
void print( MapOfIntSet const & );
int main() {
enum { N = 10 };
MapOfIntSet c; // container
for( int i = 0; i < N; ++i ) {
IntSet intSet;
for( int j = i + 1; j < N; ++j ) {
intSet.insert( j );
}
c.insert( make_pair( i, intSet ) );
}
print( c );
}
void print( MapOfIntSet const & mois ) {
for( MapOfIntSet::const_iterator cit = mois.begin(); cit != mois.end(); ++cit ) {
const int k = cit->first;
const IntSet v = cit->second;
cout << "{ " << k;
print( v );
cout << " }\n";
}
}
void print( IntSet const & is ) {
cout << " ( ";
for( IntSet::const_iterator cit = is.begin(); cit != is.end(); ++cit ) {
cout << *cit << " ";
}
cout << " )";
}