test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Operators.h
Go to the documentation of this file.
1 #ifndef OPERATORS_H_
2 #define OPERATORS_H_
3 #include "TH1F.h"
4 #include <iostream>
5 #include <vector>
6 #include <map>
7 
16 /*
17  * Pair-wise addition of std::pairs
18  */
19 template <class T> std::pair<T, T> operator+(const std::pair<T, T>& one, const std::pair<T, T>& two) {
20  std::pair<T, T> r(one.first + two.first, one.second + two.second);
21  return r;
22 }
23 
24 /*
25  * Pair-wise subtraction or std::pairs
26  */
27 template <class T> std::pair<T, T> operator-(const std::pair<T, T>& one, const std::pair<T, T>& two) {
28  std::pair<T, T> r(one.first - two.first, one.second - two.second);
29  return r;
30 }
31 
32 /*
33  * Streams std::pair contents to stream
34  */
35 template <class T> std::ostream& operator<<(std::ostream& s, const std::pair<T, T>& aT) {
36  s << "(" << aT.first << ", " << aT.second << ")";
37  return s;
38 }
39 
40 /*
41  * Extracts the value set from a std::map
42  */
43 template <class K, class V> void valueVector(const std::map<K, V>& extract, std::vector<V>& output) {
44  for(typename std::map<K, V>::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) {
45  output.push_back((*cit).second);
46  }
47 }
48 
49 /*
50  * Extracts the key set from a std::map
51  */
52 template <class K, class V> void keyVector(const std::map<K, V>& extract, std::vector<K>& output) {
53  for(typename std::map<K, V>::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) {
54  output.push_back((*cit).first);
55  }
56 }
57 
58 #endif /*OPERATORS_H_*/
void valueVector(const std::map< K, V > &extract, std::vector< V > &output)
Definition: Operators.h:43
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
void keyVector(const std::map< K, V > &extract, std::vector< K > &output)
Definition: Operators.h:52
int extract(std::vector< int > *output, const std::string &dati)