Jpp
JMap.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JMAP__
2 #define __JTOOLS__JMAP__
3 
4 #include "JTools/JCollection.hh"
6 #include "JTools/JElement.hh"
7 #include "JMath/JMath.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JTOOLS {}
15 namespace JPP { using namespace JTOOLS; }
16 
17 namespace JTOOLS {
18 
19  /**
20  * Map of pair-wise elements.
21  *
22  * The key_type and mapped_type refer to the pair-wise element of this map, respectively.
23  */
24  template<class JKey_t,
25  class JValue_t,
26  class JDistance_t = JDistance<JKey_t> >
27  class JMap :
28  public JCollection<JElement2D<JKey_t, JValue_t>, JDistance_t>,
29  public JMATH::JMath< JMap<JKey_t, JValue_t, JDistance_t> >
30  {
31  public:
32 
33  typedef JKey_t key_type;
34  typedef JValue_t mapped_type;
35 
37 
42 
43 
44  /**
45  * Default constructor.
46  */
47  JMap()
48  {}
49 
50 
51  /**
52  * Add map.
53  *
54  * \param map map
55  * \return this map
56  */
57  JMap& add(const JMap& map)
58  {
59  static_cast<container_type&>(*this).add(static_cast<const container_type&>(map));
60 
61  return *this;
62  }
63 
64 
65  /**
66  * Subtract map.
67  *
68  * \param map map
69  * \return this map
70  */
71  JMap& sub(const JMap& map)
72  {
73  static_cast<container_type&>(*this).sub(static_cast<const container_type&>(map));
74 
75  return *this;
76  }
77 
78 
79  /**
80  * Scale contents.
81  *
82  * \param value multiplication factor
83  * \return this map
84  */
85  JMap& mul(const double value)
86  {
87  static_cast<container_type&>(*this).mul(value);
88 
89  return *this;
90  }
91 
92  /**
93  * Scale contents.
94  *
95  * \param value division factor
96  * \return this map
97  */
98  JMap& div(const double value)
99  {
100  static_cast<container_type&>(*this).div(value);
101 
102  return *this;
103  }
104  };
105 
106 
107  /**
108  * Specialisation of JMapCollection for JMap.
109  */
110  template<>
112  /**
113  * Collection of elements.
114  */
115  template<class JElement_t,
118  public JCollection<JElement_t, JDistance_t>
119  {};
120  };
121 }
122 
123 #endif
JTOOLS::JMap::div
JMap & div(const double value)
Scale contents.
Definition: JMap.hh:98
JElement.hh
JTOOLS::JMap::JMap
JMap()
Default constructor.
Definition: JMap.hh:47
JCollection.hh
JTOOLS::JMap::container_type
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > container_type
Definition: JMap.hh:36
JTOOLS::JMap::add
JMap & add(const JMap &map)
Add map.
Definition: JMap.hh:57
JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t >::iterator
container_type::iterator iterator
Definition: JCollection.hh:91
JMATH::JMath
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:26
JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t >::const_reverse_iterator
container_type::const_reverse_iterator const_reverse_iterator
Definition: JCollection.hh:90
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JMap::mapped_type
JValue_t mapped_type
Definition: JMap.hh:34
JTOOLS::JMap::const_iterator
container_type::const_iterator const_iterator
Definition: JMap.hh:38
JTOOLS::JMap::mul
JMap & mul(const double value)
Scale contents.
Definition: JMap.hh:85
JTOOLS::JMap::const_reverse_iterator
container_type::const_reverse_iterator const_reverse_iterator
Definition: JMap.hh:39
JTOOLS::JMapCollection
Template class to define the corresponding JCollection for a given template JMap.
Definition: JMapCollection.hh:20
JTOOLS::JMap::reverse_iterator
container_type::reverse_iterator reverse_iterator
Definition: JMap.hh:41
JTOOLS::JMap::sub
JMap & sub(const JMap &map)
Subtract map.
Definition: JMap.hh:71
JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t >::reverse_iterator
container_type::reverse_iterator reverse_iterator
Definition: JCollection.hh:92
JMath.hh
map
const char * map
Definition: elog.cc:87
JMapCollection.hh
JTOOLS::JMap::iterator
container_type::iterator iterator
Definition: JMap.hh:40
JTOOLS::JMap
Map of pair-wise elements.
Definition: JMap.hh:27
JTOOLS::JDistance
Template class for distance evaluation.
Definition: JDistance.hh:24
JTOOLS::JCollection
General purpose class for collection of elements, see: <a href="JTools.PDF";>Collection of elements...
Definition: JCollection.hh:71
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t >::const_iterator
container_type::const_iterator const_iterator
Definition: JCollection.hh:89
JTOOLS::JMap::key_type
JKey_t key_type
Definition: JMap.hh:33