DiaDes  0.1
DIAgnosis of Discrete-Event System
MapIterators.hh
Go to the documentation of this file.
1 
8 #include <map>
9 #include <unordered_map>
10 
11 #ifndef __DIADES__UTILS__MAPITERATORS_HH
12 #define __DIADES__UTILS__MAPITERATORS_HH
13 
14 namespace Diades
15 {
16  namespace Utils
17  {
18 
19  // This code is more than largely inspired from Ian and Degski, Thanks to them
20  // user:2063546
21  // https://stackoverflow.com/users/2063546/ian
22  // user:646940
23  // https://stackoverflow.com/users/646940/degski
24 
25 
26 
27 
28  template<typename Key, typename Value>
29  using Map = std::map<Key, Value>;
30 
31  template<typename Key, typename Value>
33 
40  template<typename Key, typename Value>
41  class MapKeyIterator : public MapIterator<Key, Value>
42  {
43  public:
44 
48  MapKeyIterator() : MapIterator<Key, Value> ()
49  {
50  };
51 
56  {
57  };
58 
63  Key *operator->()
64  {
65  return(Key * const) &(MapIterator<Key, Value>::operator->()->first);
66  }
67 
72  Key & operator*()
73  {
75  }
76  };
77 
84  template<typename Key, typename Value>
85  class MapValueIterator : public MapIterator<Key, Value>
86  {
87  public:
88 
92  MapValueIterator() : MapIterator<Key, Value> ()
93  {
94  };
95 
100  {
101  };
102 
108  Value *operator->()
109  {
110  return(Value * const) &(MapIterator<Key, Value>::operator->()->second);
111  }
112 
117  Value & operator*()
118  {
119  return MapIterator<Key, Value>::operator*().second;
120  }
121  };
122 
123  template<typename Key, typename Value>
125 
132  template<typename Key, typename Value>
133  class ConstMapKeyIterator : public ConstMapIterator<Key, Value>
134  {
135  public:
136 
141  {
142  };
143 
148  {
149  };
150 
155  const Key *operator->() const
156  {
157  return(Key * const) &(ConstMapIterator<Key, Value>::operator->()->first);
158  }
159 
164  const Key & operator*() const
165  {
167  }
168  };
169 
176  template<typename Key, typename Value>
177  class ConstMapValueIterator : public ConstMapIterator<Key, Value>
178  {
179  public:
180 
185  {
186  };
187 
192  {
193  };
194 
200  const Value *operator->() const
201  {
202  return(Value * const) &(ConstMapIterator<Key, Value>::operator->()->second);
203  }
204 
209  const Value & operator*() const
210  {
212  }
213  };
214 
215 
216 
217 
218 
219  template<typename Key, typename Value>
220  using UnorderedMap = std::unordered_map<Key, Value>;
221 
222  template<typename Key, typename Value>
224 
231  template<typename Key, typename Value>
233  {
234  public:
235 
240  {
241  };
242 
247  {
248  };
249 
254  Key *operator->()
255  {
256  return(Key * const) &(UnorderedMapIterator<Key, Value>::operator->()->first);
257  }
258 
263  Key & operator*()
264  {
266  }
267  };
268 
275  template<typename Key, typename Value>
277  {
278  public:
279 
284  {
285  };
286 
291  {
292  };
293 
299  Value *operator->()
300  {
301  return(Value * const) &(UnorderedMapIterator<Key, Value>::operator->()->second);
302  }
303 
308  Value & operator*()
309  {
311  }
312  };
313 
314  template<typename Key, typename Value>
316 
323  template<typename Key, typename Value>
325  {
326  public:
327 
332  {
333  };
334 
339  {
340  };
341 
346  const Key *operator->() const
347  {
348  return(Key * const) &(ConstUnorderedMapIterator<Key, Value>::operator->()->first);
349  }
350 
355  const Key & operator*() const
356  {
358  }
359  };
360 
367  template<typename Key, typename Value>
369  {
370  public:
371 
376  {
377  };
378 
383  {
384  };
385 
391  const Value *operator->() const
392  {
393  return(Value * const) &(ConstUnorderedMapIterator<Key, Value>::operator->()->second);
394  }
395 
400  const Value & operator*() const
401  {
403  }
404  };
405 
406 
407 
408 
409 
410 
411 
412 
413  }
414 }
415 
416 #endif /* __DIADES__UTILS__MAPITERATORS_HH */
417 
std::map< Key, Value > Map
Definition: MapIterators.hh:29
typename Map< Key, Value >::const_iterator ConstMapIterator
ConstUnorderedMapKeyIterator(ConstUnorderedMapIterator< Key, Value > it)
MapValueIterator(MapIterator< Key, Value > it_)
Definition: MapIterators.hh:99
UnorderedMapKeyIterator(MapIterator< Key, Value > it)
UnorderedMapValueIterator(UnorderedMapIterator< Key, Value > it_)
ConstMapValueIterator(ConstMapIterator< Key, Value > it_)
Namespace of the Diades project.
std::unordered_map< Key, Value > UnorderedMap
MapKeyIterator(MapIterator< Key, Value > it)
Definition: MapIterators.hh:55
typename Map< Key, Value >::iterator MapIterator
Definition: MapIterators.hh:32
typename UnorderedMap< Key, Value >::const_iterator ConstUnorderedMapIterator
typename UnorderedMap< Key, Value >::iterator UnorderedMapIterator
ConstMapKeyIterator(ConstMapIterator< Key, Value > it)
ConstUnorderedMapValueIterator(ConstMapIterator< Key, Value > it_)