26 inline double f1(
const double x,
30 return x*100 +
y*10 + z;
41 return f1(key.first, key.second.first, key.second.second.first);
52 int main(
int argc,
char **argv)
62 JParser<> zap(
"Example program to test multi-dimensional map.");
69 catch(
const exception &error) {
70 FATAL(error.what() << endl);
74 const double xmin = -1.0;
75 const double xmax = +1.0;
80 JMap>::maplist JMaplist_t;
89 buffer[
x][
y][z] =
f1(
x,
y, z);
94 const JFormat_t format(6, 1, std::ios::fixed);
96 setFormat< JMultiKey<3, const double> >(format);
97 setFormat< JMultiKey<2, const double> >(format);
98 setFormat< JMultiKey<1, const double> >(format);
100 DEBUG(
"i->[second]*->(first|second)" << endl);
102 for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
104 << format << i->first <<
' '
105 << format << i->second->first <<
' '
106 << format << i->second->second->first <<
' '
107 << format << i->second->second->second << endl);
111 i->second->second->first) - i->second->second->second) <= precision,
"Test iterator equality");
114 DEBUG(
"i->[second]*->(first|second)" << endl);
116 for (JMultimap_t::super_const_reverse_iterator i = buffer.super_rbegin(); i != buffer.super_rend(); ++i) {
118 << format << i->first <<
' '
119 << format << i->second->first <<
' '
120 << format << i->second->second->first <<
' '
121 << format << i->second->second->second << endl);
125 i->second->second->first) - i->second->second->second) <= precision,
"Test iterator equality");
128 DEBUG(
"*i.[second]*.(first|second)" << endl);
130 for (JMultimap_t::super_const_reverse_iterator i = buffer.super_rbegin(); i != buffer.super_rend(); ++i) {
132 << format << (*i).first <<
' '
133 << format << (*i).second.first <<
' '
134 << format << (*i).second.second.first <<
' '
135 << format << (*i).second.second.second << endl);
139 i->second->second->first) - i->second->second->second) <= precision,
"Test iterator equality");
142 DEBUG(
"i.getKey() i.getValue()" << endl);
144 for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
146 DEBUG(i.getKey() <<
' ' << format << i.getValue() << endl);
148 ASSERT(fabs(
f1(i.getKey()) - i.
getValue()) <= precision,
"Test iterator equality");
General purpose messaging.
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
int main(int argc, char **argv)
General purpose multidimensional map based on a type list of maps.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getValue(const double x) const
Function value.