Jpp
18.1.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
JRouter.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
#include <vector>
6
7
#include "
JTools/JRouter.hh
"
8
#include "
JLang/JObjectID.hh
"
9
#include "
JIO/JFileStreamIO.hh
"
10
11
#include "
Jeep/JParser.hh
"
12
#include "
Jeep/JMessage.hh
"
13
14
15
/**
16
* \file
17
*
18
* Example program to test JTOOLS::JRouter class.
19
* \author mdejong
20
*/
21
int
main
(
int
argc,
char
**argv)
22
{
23
using namespace
std;
24
using namespace
JPP;
25
26
int
debug
;
27
28
try
{
29
30
JParser<>
zap(
"Example program to test router."
);
31
32
zap[
'd'
] =
make_field
(
debug
) = 3;
33
34
zap(argc, argv);
35
}
36
catch
(
const
exception &error) {
37
FATAL
(error.what() << endl);
38
}
39
40
vector <int>
buffer;
41
JRouter<int> router(-1);
42
43
{
44
buffer.clear();
45
router.clear();
46
47
for
(
int
i
= 1;
i
<= 1000000;
i
*= 10) {
48
buffer.push_back(
i
);
49
}
50
51
for
(
size_t
i
= 0;
i
!= buffer.size(); ++
i
) {
52
router.put(buffer[
i
], i);
53
}
54
55
ASSERT
(!router.in_range(0),
"Test of router range."
);
56
ASSERT
(!router.has(2),
"Test of router has."
);
57
58
for
(
int
i
= 1;
i
<= 1000000;
i
*= 10) {
59
ASSERT
(router.in_range(
i
),
"Test of router range."
);
60
ASSERT
(router.has(
i
),
"Test of router has."
);
61
ASSERT
(buffer[router.get(
i
)] ==
i
,
"Test of router lookup."
);
62
}
63
}
64
65
{
66
buffer.clear();
67
router.clear();
68
69
for
(
int
i
= 1000000;
i
>= 1;
i
/= 10) {
70
buffer.push_back(
i
);
71
}
72
73
for
(
size_t
i
= 0;
i
!= buffer.size(); ++
i
) {
74
router.put(buffer[
i
], i);
75
}
76
77
ASSERT
(!router.in_range(0),
"Test of router range."
);
78
ASSERT
(!router.has(2),
"Test of router has."
);
79
80
for
(
int
i
= 1000000;
i
>= 1;
i
/= 10) {
81
ASSERT
(router.in_range(
i
),
"Test of router range."
);
82
ASSERT
(router.has(
i
),
"Test of router has."
);
83
ASSERT
(buffer[router.get(
i
)] ==
i
,
"Test of router."
);
84
}
85
}
86
87
return
0;
88
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
JRouter.hh
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JFileStreamIO.hh
std::vector< int >
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
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
JObjectID.hh
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