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