ATLAS Offline Software
Loading...
Searching...
No Matches
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$
14
15
17#include <iostream>
18
19
20namespace D3PDTest {
21
22
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
33std::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
46std::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
59bool MapDumper::equal (const mapi_t& m1, const mapi_t& m2)
60{
61 return m1 == m2;
62}
63
64
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
75std::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
88std::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
101bool MapDumper::equal (const mapf_t& m1, const mapf_t& m2)
102{
103 return m1 == m2;
104}
105
106
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
117std::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
130std::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
143bool MapDumper::equal (const maps_t& m1, const maps_t& m2)
144{
145 return m1 == m2;
146}
147
148
149} // namespace D3PDTest
Helper to access contents of a stl map from python.
static void dump(const mapi_t &map)
Definition MapDumper.cxx:23
static std::vector< int > values(const mapi_t &map)
Definition MapDumper.cxx:46
std::map< std::string, int > mapi_t
Definition MapDumper.h:31
std::map< std::string, std::string > maps_t
Definition MapDumper.h:43
std::map< std::string, float > mapf_t
Definition MapDumper.h:37
static bool equal(const mapi_t &m1, const mapi_t &m2)
Definition MapDumper.cxx:59
static std::vector< std::string > keys(const mapi_t &map)
Definition MapDumper.cxx:33
STL class.