Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMultiMap.cc File Reference

Example program to test JTOOLS::JMultiMap. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JTools/JMultiMap.hh"
#include "JTools/JMap.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::JMultiMap.

Author
mdejong

Definition in file JMultiMap.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 121 of file JMultiMap.cc.

122 {
123  using namespace std;
124 
125  int debug;
126 
127  try {
128 
129  JParser<> zap("Example program to test multi-dimensional map.");
130 
131  zap['d'] = make_field(debug) = 3;
132 
133  zap(argc, argv);
134  }
135  catch(const exception &error) {
136  FATAL(error.what() << endl);
137  }
138 
139 
140  using namespace JPP;
141 
142  const double xmin = -1.0;
143  const double xmax = +1.0;
144  const double nx = 3;
145 
146  typedef JMAPLIST<JMap,
147  JMap,
148  JMap>::maplist JMaplist_t;
149 
150  typedef JMultiMap<double, double, JMaplist_t> JMultimap_t;
151 
152  JMultimap_t buffer;
153 
154  for (double x = xmin; x <= xmax; x += (xmax - xmin)/(nx - 1)) {
155  for (double y = xmin; y <= xmax; y += (xmax - xmin)/(nx - 1)) {
156  for (double z = xmin; z <= xmax; z += (xmax - xmin)/(nx - 1)) {
157  buffer[x][y][z] = x*100 + y*10 + z;
158  }
159  }
160  }
161 
162  JFormat out(cout, 6, 1);
163 
164  cout << "i->[second]*->(first|second)" << endl;
165 
166  for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
167  out << i->first << ' '
168  << i->second->first << ' '
169  << i->second->second->first << ' '
170  << i->second->second->second << endl;
171  }
172 
173  cout << "i.getKey() i.getValue()" << endl;
174 
175  for (JMultimap_t::super_const_iterator i = buffer.super_begin(); i != buffer.super_end(); ++i) {
176  out << i.getKey() << ' ' << i.getValue() << endl;
177  }
178 }
Utility class to parse command line options.
Definition: JParser.hh:1493
Map of pair-wise elements.
Definition: JMap.hh:27
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
int debug
debug level
Definition: JSirene.cc:61
Auxiliary class for recursive map list generation.
Definition: JMapList.hh:108
#define FATAL(A)
Definition: JMessage.hh:67
Multidimensional map.
Definition: JMultiMap.hh:46