ATLAS Offline Software
MapDumper.cxx
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
17 #include <iostream>
18 
19 
20 namespace D3PDTest {
21 
22 
23 void MapDumper::dump (const mapi_t& map)
24 {
25  mapi_t::const_iterator it = map.begin();
26  mapi_t::const_iterator end = map.end();
27  for (; it != end; ++it) {
28  std::cout << it->first << " " << it->second << "\n";
29  }
30 }
31 
32 
33 std::vector<std::string> MapDumper::keys (const mapi_t& map)
34 {
35  std::vector<std::string> out;
36  out.reserve (map.size());
37  mapi_t::const_iterator it = map.begin();
38  mapi_t::const_iterator end = map.end();
39  for (; it != end; ++it) {
40  out.push_back (it->first);
41  }
42  return out;
43 }
44 
45 
46 std::vector<int> MapDumper::values (const mapi_t& map)
47 {
48  std::vector<int> out;
49  out.reserve (map.size());
50  mapi_t::const_iterator it = map.begin();
51  mapi_t::const_iterator end = map.end();
52  for (; it != end; ++it) {
53  out.push_back (it->second);
54  }
55  return out;
56 }
57 
58 
59 bool MapDumper::equal (const mapi_t& m1, const mapi_t& m2)
60 {
61  return m1 == m2;
62 }
63 
64 
65 void MapDumper::dump (const mapf_t& map)
66 {
67  mapf_t::const_iterator it = map.begin();
68  mapf_t::const_iterator end = map.end();
69  for (; it != end; ++it) {
70  std::cout << it->first << " " << it->second << "\n";
71  }
72 }
73 
74 
75 std::vector<std::string> MapDumper::keys (const mapf_t& map)
76 {
77  std::vector<std::string> out;
78  out.reserve (map.size());
79  mapf_t::const_iterator it = map.begin();
80  mapf_t::const_iterator end = map.end();
81  for (; it != end; ++it) {
82  out.push_back (it->first);
83  }
84  return out;
85 }
86 
87 
88 std::vector<float> MapDumper::values (const mapf_t& map)
89 {
90  std::vector<float> out;
91  out.reserve (map.size());
92  mapf_t::const_iterator it = map.begin();
93  mapf_t::const_iterator end = map.end();
94  for (; it != end; ++it) {
95  out.push_back (it->second);
96  }
97  return out;
98 }
99 
100 
101 bool MapDumper::equal (const mapf_t& m1, const mapf_t& m2)
102 {
103  return m1 == m2;
104 }
105 
106 
107 void MapDumper::dump (const maps_t& map)
108 {
109  maps_t::const_iterator it = map.begin();
110  maps_t::const_iterator end = map.end();
111  for (; it != end; ++it) {
112  std::cout << it->first << " " << it->second << "\n";
113  }
114 }
115 
116 
117 std::vector<std::string> MapDumper::keys (const maps_t& map)
118 {
119  std::vector<std::string> out;
120  out.reserve (map.size());
121  maps_t::const_iterator it = map.begin();
122  maps_t::const_iterator end = map.end();
123  for (; it != end; ++it) {
124  out.push_back (it->first);
125  }
126  return out;
127 }
128 
129 
130 std::vector<std::string> MapDumper::values (const maps_t& map)
131 {
132  std::vector<std::string> out;
133  out.reserve (map.size());
134  maps_t::const_iterator it = map.begin();
135  maps_t::const_iterator end = map.end();
136  for (; it != end; ++it) {
137  out.push_back (it->second);
138  }
139  return out;
140 }
141 
142 
143 bool MapDumper::equal (const maps_t& m1, const maps_t& m2)
144 {
145  return m1 == m2;
146 }
147 
148 
149 } // namespace D3PDTest
python.SystemOfUnits.m2
int m2
Definition: SystemOfUnits.py:92
D3PDTest::MapDumper::equal
static bool equal(const mapi_t &m1, const mapi_t &m2)
Definition: MapDumper.cxx:59
skel.it
it
Definition: skel.GENtoEVGEN.py:396
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
D3PDTest::MapDumper::values
static std::vector< int > values(const mapi_t &map)
Definition: MapDumper.cxx:46
python.changerun.m1
m1
Definition: changerun.py:32
MapDumper.h
Helper to access contents of a stl map from python.
D3PDTest::MapDumper::dump
static void dump(const mapi_t &map)
Definition: MapDumper.cxx:23
D3PDTest::MapDumper::mapf_t
std::map< std::string, float > mapf_t
Definition: MapDumper.h:37
D3PDTest::MapDumper::maps_t
std::map< std::string, std::string > maps_t
Definition: MapDumper.h:43
D3PDTest
Definition: MapDumper.h:25
D3PDTest::MapDumper::keys
static std::vector< std::string > keys(const mapi_t &map)
Definition: MapDumper.cxx:33
D3PDTest::MapDumper::mapi_t
std::map< std::string, int > mapi_t
Definition: MapDumper.h:31