#include #include #include #include "JTools/JMultiMap.hh" #include "JTools/JMap.hh" #include "JLang/JManip.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JTOOLS::JMultiMap. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test multi-dimensional map."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; const double xmin = -1.0; const double xmax = +1.0; const double nx = 3; typedef JMAPLIST::maplist JMaplist_t; typedef JMultiMap JMultimap_t; JMultimap_t buffer; for (double x = xmin; x <= xmax; x += (xmax - xmin)/(nx - 1)) { for (double y = xmin; y <= xmax; y += (xmax - xmin)/(nx - 1)) { for (double z = xmin; z <= xmax; z += (xmax - xmin)/(nx - 1)) { buffer[x][y][z] = x*100 + y*10 + z; } } } const JFormat_t format(6, 1, std::ios::fixed); setFormat< JMultiKey<3, const double> >(format); setFormat< JMultiKey<2, const double> >(format); setFormat< JMultiKey<1, const double> >(format); cout << "i->[second]*->(first|second)" << endl; for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) { cout << format << i->first << ' ' << format << i->second->first << ' ' << format << i->second->second->first << ' ' << format << i->second->second->second << endl; } cout << "i.getKey() i.getValue()" << endl; for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) { cout << i.getKey() << ' ' << format << i.getValue() << endl; } }