#include #include #include "JTools/JHashMap.hh" #include "JTools/JMultiHashMap.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JTOOLS::JHashMap class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test hash map."); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; typedef JTYPELIST::typelist typelist; typedef JTuple key_type; typedef JHashMap hash_map; hash_map buffer; buffer[1][1][3] = "mies"; buffer[2][1][2] = "noot"; buffer[3][1][1] = "aap"; key_type key(2, 4, 6); buffer.put(key, "hello world"); cout << "Has " << key << " ? " << buffer.has(key) << endl; for (hash_map::super_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) { i.getValue() += '!'; } for (hash_map::const_iterator i0 = buffer.begin(); i0 != buffer.end(); ++i0) { for (hash_map::mapped_type::const_iterator i1 = i0->second.begin(); i1 != i0->second.end(); ++i1) { for (hash_map::mapped_type::mapped_type::const_iterator i2 = i1->second.begin(); i2 != i1->second.end(); ++i2) { cout << i0->first << ' ' << i1->first << ' ' << i2->first << ' ' << i2->second << endl; } } } for (hash_map::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) { cout << i.getKey() << ' ' << i.getValue() << endl; } }