Jpp
18.5.0
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JTools
JHashMap.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JTools/JHashMap.hh
"
6
#include "
JTools/JMultiHashMap.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
/**
13
* \file
14
*
15
* Example program to test JTOOLS::JHashMap class.
16
* \author mdejong
17
*/
18
int
main
(
int
argc,
char
**argv)
19
{
20
using namespace
std;
21
22
int
debug
;
23
24
try
{
25
26
JParser<>
zap(
"Example program to test hash map."
);
27
28
zap[
'd'
] =
make_field
(
debug
) = 0;
29
30
zap(argc, argv);
31
}
32
catch
(
const
exception &error) {
33
FATAL
(error.what() << endl);
34
}
35
36
37
using namespace
JPP;
38
39
typedef
JTYPELIST<int, int, int>::typelist
typelist;
40
41
typedef
JTuple <typelist> key_type;
42
typedef
JHashMap<typelist, string> hash_map;
43
44
hash_map buffer;
45
46
buffer[1][1][3] =
"mies"
;
47
buffer[2][1][2] =
"noot"
;
48
buffer[3][1][1] =
"aap"
;
49
50
key_type key(2, 4, 6);
51
52
buffer.put(key,
"hello world"
);
53
54
cout <<
"Has "
<< key <<
" ? "
<< buffer.has(key) << endl;
55
56
57
for
(hash_map::super_iterator
i
= buffer.super_begin();
i
!= buffer.super_end(); ++
i
) {
58
i
.getValue() +=
'!'
;
59
}
60
61
for
(hash_map::const_iterator i0 = buffer.begin(); i0 != buffer.end(); ++i0) {
62
for
(hash_map::mapped_type::const_iterator i1 = i0->second.begin(); i1 != i0->second.end(); ++i1) {
63
for
(hash_map::mapped_type::mapped_type::const_iterator i2 = i1->second.begin(); i2 != i1->second.end(); ++i2) {
64
cout << i0->first <<
' '
<< i1->first <<
' '
<< i2->first <<
' '
<< i2->second << endl;
65
}
66
}
67
}
68
69
for
(hash_map::super_const_iterator
i
= buffer.super_begin();
i
!= buffer.super_end(); ++
i
) {
70
cout <<
i
.getKey() <<
' '
<<
i
.getValue() << endl;
71
}
72
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
JMultiHashMap.hh
General purpose class for multidimensional hash maps.
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JHashMap.hh
General purpose class for hash map of unique elements.
JLANG::JTypeList
Type list.
Definition:
JTypeList.hh:22
i
then rm i
Definition:
JEvtReweightMupageParameterScan.sh:309
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5