Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JMappableCollection.hh
Go to the documentation of this file.
1#ifndef __JTOOLS__JMAPPABLECOLLECTION__
2#define __JTOOLS__JMAPPABLECOLLECTION__
3
4#include "JLang/JClass.hh"
5
6
7/**
8 * \author mdejong
9 */
10
11namespace JTOOLS {}
12namespace JPP { using namespace JTOOLS; }
13
14namespace JTOOLS {
15
16 using JLANG::JClass;
17
18
19 /**
20 * Template interface definition for associative collection of elements.
21 * The concrete associative collection should implement the following methods.
22 * <pre>
23 * void clear();
24 *
25 * mapped_type& get(key_type key);
26 * </pre>
27 * This class implements the operator <tt>[key_type key]</tt> and method <tt>put(key_type key, mapped_type value)</tt>.
28 */
29 template<class JKey_t, class JValue_t>
31 {
32
33 typedef JKey_t key_type;
34 typedef JValue_t mapped_type;
35
36 /**
37 * Virtual destructor.
38 */
40 {}
41
42
43 /**
44 * Clear.
45 */
46 virtual void clear() = 0;
47
48
49 /**
50 * Get mapped value.
51 *
52 * \param key key
53 * \return value
54 */
55 virtual const mapped_type& get(typename JClass<key_type>::argument_type key) const = 0;
56
57
58 /**
59 * Get mapped value.
60 *
61 * \param key key
62 * \return value
63 */
65
66
67 /**
68 * Get mapped value.
69 *
70 * \param key key
71 * \return value
72 */
74 {
75 return get(key);
76 }
77
78
79 /**
80 * Get mapped value.
81 *
82 * \param key key
83 * \return value
84 */
86 {
87 return get(key);
88 }
89
90
91 /**
92 * Put pair-wise element (key,value) into collection.
93 *
94 * \param key key
95 * \param value value
96 */
99 {
100 get(key) = value;
101 }
102 };
103
104
105 /**
106 * Auxiliary class to define JMappableCollection for given template.
107 */
108 template<class T>
109 struct JMappable {
110 /**
111 * Type definition of JMappableCollection.
112 */
113 typedef JMappableCollection<typename T::abscissa_type,
114 typename T::ordinate_type> map_type;
115 };
116}
117
118#endif
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Template for generic class types.
Definition JClass.hh:80
JArgument< T >::argument_type argument_type
Definition JClass.hh:82
Template interface definition for associative collection of elements.
void put(typename JClass< key_type > ::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.
virtual ~JMappableCollection()
Virtual destructor.
virtual mapped_type & get(typename JClass< key_type >::argument_type key)=0
Get mapped value.
mapped_type & operator[](typename JClass< key_type >::argument_type key)
Get mapped value.
const mapped_type & operator[](typename JClass< key_type >::argument_type key) const
Get mapped value.
virtual void clear()=0
Clear.
virtual const mapped_type & get(typename JClass< key_type >::argument_type key) const =0
Get mapped value.
Auxiliary class to define JMappableCollection for given template.
JMappableCollection< typename T::abscissa_type, typename T::ordinate_type > map_type
Type definition of JMappableCollection.