Jpp 20.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JHashMap.cc File Reference

Example program to test JTOOLS::JHashMap class. More...

#include <iostream>
#include <iomanip>
#include "JTools/JHashMap.hh"
#include "JTools/JMultiHashMap.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JTOOLS::JHashMap class.

Author
mdejong

Definition in file JHashMap.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 18 of file JHashMap.cc.

19{
20 using namespace std;
21 using namespace JPP;
22
23 int debug;
24
25 try {
26
27 JParser<> zap("Example program to test hash map.");
28
29 zap['d'] = make_field(debug) = 0;
30
31 zap(argc, argv);
32 }
33 catch(const exception &error) {
34 FATAL(error.what() << endl);
35 }
36
37
39
40 typedef JTuple <typelist> key_type;
41 typedef JHashMap<typelist, string> hash_map;
42
43 hash_map buffer;
44
45 buffer[1][1][3] = "mies";
46 buffer[2][1][2] = "noot";
47 buffer[3][1][1] = "aap";
48
49 key_type key(2, 4, 6);
50
51 buffer.put(key, "hello world");
52
53 cout << "Has " << key << " ? " << buffer.has(key) << endl;
54
55
56 for (hash_map::super_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
57 i.getValue() += '!';
58 }
59
60 for (hash_map::const_iterator i0 = buffer.begin(); i0 != buffer.end(); ++i0) {
61 for (hash_map::mapped_type::const_iterator i1 = i0->second.begin(); i1 != i0->second.end(); ++i1) {
62 for (hash_map::mapped_type::mapped_type::const_iterator i2 = i1->second.begin(); i2 != i1->second.end(); ++i2) {
63 cout << i0->first << ' ' << i1->first << ' ' << i2->first << ' ' << i2->second << endl;
64 }
65 }
66 }
67
68 for (hash_map::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
69 cout << i.getKey() << ' ' << i.getValue() << endl;
70 }
71}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Type list.
Definition JTypeList.hh:23
General purpose class for hash map of unique keys.
Definition JHashMap.hh:75