Jpp  18.0.0-rc.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  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  */
50  JMap()
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
container_type::const_reverse_iterator const_reverse_iterator
Definition: JMap.hh:42
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:109
General purpose class for collection of elements, see: &lt;a href=&quot;JTools.PDF&quot;;&gt;Collection of elements...
Definition: JCollection.hh:73
The elements in a collection are sorted according to their abscissa values and a given distance opera...
Template class for distance evaluation.
Definition: JDistance.hh:24
Map of pair-wise elements.
Definition: JMap.hh:30
container_type::const_iterator const_iterator
Definition: JMap.hh:41
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: JCollection.hh:92
General purpose class for a collection of sorted elements.
Template class to define the corresponding JCollection for a given template JMap. ...
JMap & div(const double value)
Scale contents.
Definition: JMap.hh:101
container_type::reverse_iterator reverse_iterator
Definition: JMap.hh:44
JMap & sub(const JMap &map)
Subtract map.
Definition: JMap.hh:74
Base class for data structures with artithmetic capabilities.
JKey_t key_type
Definition: JMap.hh:36
container_type::iterator iterator
Definition: JMap.hh:43
const char * map
Definition: elog.cc:87
JValue_t mapped_type
Definition: JMap.hh:37
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