equal
deleted
inserted
replaced
10 |
10 |
11 #include <map> |
11 #include <map> |
12 |
12 |
13 namespace hugo { |
13 namespace hugo { |
14 |
14 |
|
15 /// Base class of maps. |
|
16 |
|
17 template<typename K, typename T> |
|
18 class MapBase |
|
19 { |
|
20 public: |
|
21 /// |
|
22 typedef K KeyType; |
|
23 /// |
|
24 typedef T ValueType; |
|
25 }; |
|
26 |
15 /// Null map. (aka DoNothingMap) |
27 /// Null map. (aka DoNothingMap) |
16 |
28 |
17 /// If you have to provide a map only for its type definitions, |
29 /// If you have to provide a map only for its type definitions, |
18 /// or if you have to provide a writable map, but will not use the |
30 /// or if you have to provide a writable map, but will not use the |
19 /// data written to it... |
31 /// data written to it... |
20 template<typename K, typename T> |
32 template<typename K, typename T> |
21 class NullMap |
33 class NullMap : public MapBase<K,T> |
22 { |
34 { |
23 public: |
35 public: |
24 typedef K KeyType; |
|
25 typedef T ValueType; |
|
26 |
36 |
27 T operator[](const K&) const { return T(); } |
37 T operator[](const K&) const { return T(); } |
28 void set(const K&, const T&) {} |
38 void set(const K&, const T&) {} |
29 ///\bug when update is removed from map concepts by being dynamic |
39 ///\bug when update is removed from map concepts by being dynamic |
30 ///stuffs, this line have to be removed. |
40 ///stuffs, this line have to be removed. |
35 /// Constant map. |
45 /// Constant map. |
36 |
46 |
37 /// This is a readable map which assignes a specified value to each key. |
47 /// This is a readable map which assignes a specified value to each key. |
38 /// In other aspects it is equivalent to the \ref NullMap |
48 /// In other aspects it is equivalent to the \ref NullMap |
39 template<typename K, typename T> |
49 template<typename K, typename T> |
40 class ConstMap |
50 class ConstMap : public MapBase<K,T> |
41 { |
51 { |
42 T v; |
52 T v; |
43 public: |
53 public: |
44 typedef K KeyType; |
|
45 typedef T ValueType; |
|
46 |
54 |
47 ConstMap() {} |
55 ConstMap() {} |
48 ConstMap(const T &_v) : v(_v) {} |
56 ConstMap(const T &_v) : v(_v) {} |
49 |
57 |
50 T operator[](const K&) const { return v; } |
58 T operator[](const K&) const { return v; } |