gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 2 0
merge default
2 files changed with 124 insertions and 67 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -48,6 +48,7 @@
48 48

	
49 49
      /// Returns the value associated with a key.
50 50

	
51
      /// Returns the value associated with a key.
51 52
      /// \bug Value shouldn't need to be default constructible.
52 53
      ///
53 54
      Value operator[](const Key &) const {return Value();}
... ...
@@ -113,7 +114,7 @@
113 114
      };
114 115
    };
115 116

	
116
    /// Read/Writable map concept
117
    /// Read/writable map concept
117 118
    
118 119
    /// Read/writable map concept.
119 120
    ///
... ...
@@ -146,6 +147,7 @@
146 147
    
147 148
    /// Dereferable map concept.
148 149
    ///
150
    /// \todo Rethink this concept.
149 151
    template<typename K, typename T, typename R, typename CR>
150 152
    class ReferenceMap : public ReadWriteMap<K,T>
151 153
    {
... ...
@@ -165,14 +167,13 @@
165 167
      Value tmp;
166 168
    public:
167 169

	
168
      ///Returns a reference to the value associated to a key.
170
      ///Returns a reference to the value associated with a key.
169 171
      Reference operator[](const Key &) { return tmp; }
170
      ///Returns a const reference to the value associated to a key.
172
      ///Returns a const reference to the value associated with a key.
171 173
      ConstReference operator[](const Key &) const { return tmp; }
172 174
      /// Sets the value associated with a key.
173 175
      void set(const Key &k,const Value &t) { operator[](k)=t; }
174 176

	
175
      /// \todo Rethink this concept. 
176 177
      template<typename _ReferenceMap>
177 178
      struct ReferenceMapConcept {
178 179

	
Ignore white space 6 line context
... ...
@@ -81,8 +81,9 @@
81 81

	
82 82
  /// Constant map.
83 83

	
84
  /// This is a readable map which assigns a specified value to each key.
85
  /// In other aspects it is equivalent to the \c NullMap.
84
  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
85
  /// specified value to each key.
86
  /// In other aspects it is equivalent to \c NullMap.
86 87
  template<typename K, typename T>
87 88
  class ConstMap : public MapBase<K, T> {
88 89
  private:
... ...
@@ -133,8 +134,9 @@
133 134

	
134 135
  /// Constant map with inlined constant value.
135 136

	
136
  /// This is a readable map which assigns a specified value to each key.
137
  /// In other aspects it is equivalent to the \c NullMap.
137
  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
138
  /// specified value to each key.
139
  /// In other aspects it is equivalent to \c NullMap.
138 140
  template<typename K, typename V, V v>
139 141
  class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
140 142
  public:
... ...
@@ -149,7 +151,7 @@
149 151
    void set(const K&, const V&) { }
150 152
  };
151 153

	
152
  ///Returns a \c ConstMap class
154
  ///Returns a \c ConstMap class with inlined value
153 155

	
154 156
  ///This function just returns a \c ConstMap class with inlined value.
155 157
  ///\relates ConstMap
... ...
@@ -158,26 +160,29 @@
158 160
    return ConstMap<K, Const<V, v> >();
159 161
  }
160 162

	
161
  ///Map based on std::map
163
  ///Map based on \c std::map
162 164

	
163 165
  ///This is essentially a wrapper for \c std::map with addition that
164 166
  ///you can specify a default value different from \c Value().
167
  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
165 168
  template <typename K, typename T, typename Compare = std::less<K> >
166
  class StdMap {
169
  class StdMap : public MapBase<K, T> {
167 170
    template <typename K1, typename T1, typename C1>
168 171
    friend class StdMap;
169 172
  public:
170 173

	
171
    typedef True ReferenceMapTag;
174
    typedef MapBase<K, T> Parent;
172 175
    ///Key type
173
    typedef K Key;
176
    typedef typename Parent::Key Key;
174 177
    ///Value type
175
    typedef T Value;
178
    typedef typename Parent::Value Value;
176 179
    ///Reference Type
177 180
    typedef T& Reference;
178 181
    ///Const reference type
179 182
    typedef const T& ConstReference;
180 183

	
184
    typedef True ReferenceMapTag;
185

	
181 186
  private:
182 187
    
183 188
    typedef std::map<K, T, Compare> Map;
... ...
@@ -188,13 +193,13 @@
188 193

	
189 194
    /// Constructor with specified default value
190 195
    StdMap(const T& value = T()) : _value(value) {}
191
    /// \brief Constructs the map from an appropriate std::map, and explicitly
192
    /// specifies a default value.
196
    /// \brief Constructs the map from an appropriate \c std::map, and 
197
    /// explicitly specifies a default value.
193 198
    template <typename T1, typename Comp1>
194 199
    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
195 200
      : _map(map.begin(), map.end()), _value(value) {}
196 201
    
197
    /// \brief Constructs a map from an other StdMap.
202
    /// \brief Constructs a map from an other \ref StdMap.
198 203
    template<typename T1, typename Comp1>
199 204
    StdMap(const StdMap<Key, T1, Comp1> &c) 
200 205
      : _map(c._map.begin(), c._map.end()), _value(c._value) {}
... ...
@@ -239,33 +244,57 @@
239 244
    }    
240 245

	
241 246
  };
247
  
248
  ///Returns a \c StdMap class
249

	
250
  ///This function just returns a \c StdMap class with specified 
251
  ///default value.
252
  ///\relates StdMap
253
  template<typename K, typename V, typename Compare = std::less<K> > 
254
  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
255
    return StdMap<K, V, Compare>(value);
256
  }
257

	
258
  ///Returns a \c StdMap class created from an appropriate std::map
259

	
260
  ///This function just returns a \c StdMap class created from an 
261
  ///appropriate std::map.
262
  ///\relates StdMap
263
  template<typename K, typename V, typename Compare = std::less<K> > 
264
  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, 
265
                                       const V& value = V() ) {
266
    return StdMap<K, V, Compare>(map, value);
267
  }
242 268

	
243 269
  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
244 270
  ///
245
  /// The current map has the <tt>[0..size-1]</tt> keyset and the values
271
  /// This map has the <tt>[0..size-1]</tt> keyset and the values
246 272
  /// are stored in a \c std::vector<T>  container. It can be used with
247 273
  /// some data structures, for example \c UnionFind, \c BinHeap, when 
248
  /// the used items are small integer numbers. 
274
  /// the used items are small integer numbers.
275
  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
249 276
  ///
250 277
  /// \todo Revise its name
251 278
  template <typename T>
252
  class IntegerMap {
279
  class IntegerMap : public MapBase<int, T> {
253 280

	
254 281
    template <typename T1>
255 282
    friend class IntegerMap;
256 283

	
257 284
  public:
258 285

	
259
    typedef True ReferenceMapTag;
286
    typedef MapBase<int, T> Parent;
260 287
    ///\e
261
    typedef int Key;
288
    typedef typename Parent::Key Key;
262 289
    ///\e
263
    typedef T Value;
290
    typedef typename Parent::Value Value;
264 291
    ///\e
265 292
    typedef T& Reference;
266 293
    ///\e
267 294
    typedef const T& ConstReference;
268 295

	
296
    typedef True ReferenceMapTag;
297

	
269 298
  private:
270 299
    
271 300
    typedef std::vector<T> Vector;
... ...
@@ -276,12 +305,12 @@
276 305
    /// Constructor with specified default value
277 306
    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
278 307

	
279
    /// \brief Constructs the map from an appropriate std::vector.
308
    /// \brief Constructs the map from an appropriate \c std::vector.
280 309
    template <typename T1>
281 310
    IntegerMap(const std::vector<T1>& vector) 
282 311
      : _vector(vector.begin(), vector.end()) {}
283 312
    
284
    /// \brief Constructs a map from an other IntegerMap.
313
    /// \brief Constructs a map from an other \ref IntegerMap.
285 314
    template <typename T1>
286 315
    IntegerMap(const IntegerMap<T1> &c) 
287 316
      : _vector(c._vector.begin(), c._vector.end()) {}
... ...
@@ -313,6 +342,15 @@
313 342
    }
314 343

	
315 344
  };
345
  
346
  ///Returns an \c IntegerMap class
347

	
348
  ///This function just returns an \c IntegerMap class.
349
  ///\relates IntegerMap
350
  template<typename T>
351
  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
352
    return IntegerMap<T>(size, value);
353
  }
316 354

	
317 355
  /// @}
318 356

	
... ...
@@ -349,7 +387,7 @@
349 387
  ///\brief Convert the \c Value of a map to another type using
350 388
  ///the default conversion.
351 389
  ///
352
  ///This \c concepts::ReadMap "read only map"
390
  ///This \ref concepts::ReadMap "read only map"
353 391
  ///converts the \c Value of a map to type \c T.
354 392
  ///Its \c Key is inherited from \c M.
355 393
  template <typename M, typename T> 
... ...
@@ -366,9 +404,7 @@
366 404
    ///\param _m is the underlying map.
367 405
    ConvertMap(const M &_m) : m(_m) {};
368 406

	
369
    /// \brief The subscript operator.
370
    ///
371
    /// The subscript operator.
407
    ///\e
372 408
    Value operator[](const Key& k) const {return m[k];}
373 409
  };
374 410
  
... ...
@@ -405,10 +441,19 @@
405 441
    ///\e
406 442
    Value operator[](Key k) const {return m[k];}
407 443
  };
444
  
445
  ///Returns a \c SimpleMap class
446

	
447
  ///This function just returns a \c SimpleMap class.
448
  ///\relates SimpleMap
449
  template<typename M>
450
  inline SimpleMap<M> simpleMap(const M &m) {
451
    return SimpleMap<M>(m);
452
  }
408 453

	
409 454
  ///Simple writable wrapping of a map
410 455

	
411
  ///This \ref concepts::WriteMap "write map" returns the simple
456
  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
412 457
  ///wrapping of the given map. Sometimes the reference maps cannot be
413 458
  ///combined with simple read-write maps. This map adaptor wraps the
414 459
  ///given map to simple read-write map.
... ...
@@ -433,12 +478,21 @@
433 478
    void set(Key k, const Value& c) { m.set(k, c); }
434 479
  };
435 480

	
481
  ///Returns a \c SimpleWriteMap class
482

	
483
  ///This function just returns a \c SimpleWriteMap class.
484
  ///\relates SimpleWriteMap
485
  template<typename M>
486
  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
487
    return SimpleWriteMap<M>(m);
488
  }
489

	
436 490
  ///Sum of two maps
437 491

	
438
  ///This \c concepts::ReadMap "read only map" returns the sum of the two
492
  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
439 493
  ///given maps.
440 494
  ///Its \c Key and \c Value are inherited from \c M1.
441
  ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
495
  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
442 496
  template<typename M1, typename M2> 
443 497
  class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
444 498
    const M1& m1;
... ...
@@ -458,7 +512,7 @@
458 512
  ///Returns an \c AddMap class
459 513

	
460 514
  ///This function just returns an \c AddMap class.
461
  ///\todo How to call these type of functions?
515
  ///\todo Extend the documentation: how to call these type of functions?
462 516
  ///
463 517
  ///\relates AddMap
464 518
  template<typename M1, typename M2> 
... ...
@@ -468,7 +522,7 @@
468 522

	
469 523
  ///Shift a map with a constant.
470 524

	
471
  ///This \c concepts::ReadMap "read only map" returns the sum of the
525
  ///This \ref concepts::ReadMap "read only map" returns the sum of the
472 526
  ///given map and a constant value.
473 527
  ///Its \c Key and \c Value are inherited from \c M.
474 528
  ///
... ...
@@ -504,7 +558,7 @@
504 558

	
505 559
  ///Shift a map with a constant (ReadWrite version).
506 560

	
507
  ///This \c concepts::ReadWriteMap "read-write map" returns the sum of the
561
  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
508 562
  ///given map and a constant value. It makes also possible to write the map.
509 563
  ///Its \c Key and \c Value are inherited from \c M.
510 564
  ///
... ...
@@ -550,7 +604,7 @@
550 604

	
551 605
  ///Difference of two maps
552 606

	
553
  ///This \c concepts::ReadMap "read only map" returns the difference
607
  ///This \ref concepts::ReadMap "read only map" returns the difference
554 608
  ///of the values of the two given maps.
555 609
  ///Its \c Key and \c Value are inherited from \c M1.
556 610
  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
... ...
@@ -583,7 +637,7 @@
583 637

	
584 638
  ///Product of two maps
585 639

	
586
  ///This \c concepts::ReadMap "read only map" returns the product of the
640
  ///This \ref concepts::ReadMap "read only map" returns the product of the
587 641
  ///values of the two given maps.
588 642
  ///Its \c Key and \c Value are inherited from \c M1.
589 643
  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
... ...
@@ -613,7 +667,7 @@
613 667
 
614 668
  ///Scales a map with a constant.
615 669

	
616
  ///This \c concepts::ReadMap "read only map" returns the value of the
670
  ///This \ref concepts::ReadMap "read only map" returns the value of the
617 671
  ///given map multiplied from the left side with a constant value.
618 672
  ///Its \c Key and \c Value are inherited from \c M.
619 673
  ///
... ...
@@ -649,7 +703,7 @@
649 703

	
650 704
  ///Scales a map with a constant (ReadWrite version).
651 705

	
652
  ///This \c concepts::ReadWriteMap "read-write map" returns the value of the
706
  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
653 707
  ///given map multiplied from the left side with a constant value. It can
654 708
  ///also be used as write map if the \c / operator is defined between
655 709
  ///\c Value and \c C and the given multiplier is not zero.
... ...
@@ -697,7 +751,7 @@
697 751

	
698 752
  ///Quotient of two maps
699 753

	
700
  ///This \c concepts::ReadMap "read only map" returns the quotient of the
754
  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
701 755
  ///values of the two given maps.
702 756
  ///Its \c Key and \c Value are inherited from \c M1.
703 757
  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
... ...
@@ -727,7 +781,7 @@
727 781
  
728 782
  ///Composition of two maps
729 783

	
730
  ///This \c concepts::ReadMap "read only map" returns the composition of
784
  ///This \ref concepts::ReadMap "read only map" returns the composition of
731 785
  ///two given maps.
732 786
  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
733 787
  ///then for
... ...
@@ -778,7 +832,7 @@
778 832

	
779 833
  ///Combine of two maps using an STL (binary) functor.
780 834
  ///
781
  ///This \c concepts::ReadMap "read only map" takes two maps and a
835
  ///This \ref concepts::ReadMap "read only map" takes two maps and a
782 836
  ///binary functor and returns the composition of the two
783 837
  ///given maps unsing the functor. 
784 838
  ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
... ...
@@ -851,7 +905,7 @@
851 905

	
852 906
  ///Negative value of a map
853 907

	
854
  ///This \c concepts::ReadMap "read only map" returns the negative
908
  ///This \ref concepts::ReadMap "read only map" returns the negative
855 909
  ///value of the value returned by the given map.
856 910
  ///Its \c Key and \c Value are inherited from \c M.
857 911
  ///The unary \c - operator must be defined for \c Value, of course.
... ...
@@ -873,7 +927,7 @@
873 927
  
874 928
  ///Negative value of a map (ReadWrite version)
875 929

	
876
  ///This \c concepts::ReadWriteMap "read-write map" returns the negative
930
  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
877 931
  ///value of the value returned by the given map.
878 932
  ///Its \c Key and \c Value are inherited from \c M.
879 933
  ///The unary \c - operator must be defined for \c Value, of course.
... ...
@@ -915,7 +969,7 @@
915 969

	
916 970
  ///Absolute value of a map
917 971

	
918
  ///This \c concepts::ReadMap "read only map" returns the absolute value
972
  ///This \ref concepts::ReadMap "read only map" returns the absolute value
919 973
  ///of the value returned by the given map.
920 974
  ///Its \c Key and \c Value are inherited from \c M. 
921 975
  ///\c Value must be comparable to \c 0 and the unary \c -
... ...
@@ -949,13 +1003,14 @@
949 1003

	
950 1004
  ///Converts an STL style functor to a map
951 1005

	
952
  ///This \c concepts::ReadMap "read only map" returns the value
1006
  ///This \ref concepts::ReadMap "read only map" returns the value
953 1007
  ///of a given functor.
954 1008
  ///
955 1009
  ///Template parameters \c K and \c V will become its
956 1010
  ///\c Key and \c Value. 
957 1011
  ///In most cases they have to be given explicitly because a 
958
  ///functor typically does not provide such typedefs.
1012
  ///functor typically does not provide \c argument_type and 
1013
  ///\c result_type typedefs.
959 1014
  ///
960 1015
  ///Parameter \c F is the type of the used functor.
961 1016
  ///
... ...
@@ -980,8 +1035,9 @@
980 1035

	
981 1036
  ///This function just returns a \c FunctorMap class.
982 1037
  ///
983
  ///It is specialized for adaptable function classes and
984
  ///C++ functions.
1038
  ///This function is specialized for adaptable binary function
1039
  ///classes and C++ functions.
1040
  ///
985 1041
  ///\relates FunctorMap
986 1042
  template<typename K, typename V, typename F> inline 
987 1043
  FunctorMap<F, K, V> functorMap(const F &f) {
... ...
@@ -1004,10 +1060,10 @@
1004 1060
  ///Converts a map to an STL style (unary) functor
1005 1061

	
1006 1062
  ///This class Converts a map to an STL style (unary) functor.
1007
  ///that is it provides an <tt>operator()</tt> to read its values.
1063
  ///That is it provides an <tt>operator()</tt> to read its values.
1008 1064
  ///
1009 1065
  ///For the sake of convenience it also works as
1010
  ///a ususal \c concepts::ReadMap "readable map",
1066
  ///a ususal \ref concepts::ReadMap "readable map",
1011 1067
  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
1012 1068
  ///
1013 1069
  ///\sa FunctorMap
... ...
@@ -1039,14 +1095,14 @@
1039 1095
    return MapFunctor<M>(m);
1040 1096
  }
1041 1097

	
1042
  ///Applies all map setting operations to two maps
1098
  ///Just readable version of \ref ForkWriteMap
1043 1099

	
1044
  ///This map has two \c concepts::ReadMap "readable map"
1100
  ///This map has two \ref concepts::ReadMap "readable map"
1045 1101
  ///parameters and each read request will be passed just to the
1046
  ///first map. This class is the just readable map type of the ForkWriteMap.
1102
  ///first map. This class is the just readable map type of \c ForkWriteMap.
1047 1103
  ///
1048 1104
  ///The \c Key and \c Value are inherited from \c M1.
1049
  ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
1105
  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
1050 1106
  ///
1051 1107
  ///\sa ForkWriteMap
1052 1108
  ///
... ...
@@ -1069,14 +1125,14 @@
1069 1125

	
1070 1126
  ///Applies all map setting operations to two maps
1071 1127

	
1072
  ///This map has two \c concepts::WriteMap "writable map"
1128
  ///This map has two \ref concepts::WriteMap "writable map"
1073 1129
  ///parameters and each write request will be passed to both of them.
1074
  ///If \c M1 is also \c concepts::ReadMap "readable",
1130
  ///If \c M1 is also \ref concepts::ReadMap "readable",
1075 1131
  ///then the read operations will return the
1076 1132
  ///corresponding values of \c M1.
1077 1133
  ///
1078 1134
  ///The \c Key and \c Value are inherited from \c M1.
1079
  ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
1135
  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
1080 1136
  ///
1081 1137
  ///\sa ForkMap
1082 1138
  template<typename  M1, typename M2> 
... ...
@@ -1120,9 +1176,9 @@
1120 1176
  
1121 1177
  ///Logical 'not' of a map
1122 1178
  
1123
  ///This bool \c concepts::ReadMap "read only map" returns the 
1179
  ///This bool \ref concepts::ReadMap "read only map" returns the 
1124 1180
  ///logical negation of the value returned by the given map.
1125
  ///Its \c Key is inherited from \c M, its Value is \c bool.
1181
  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
1126 1182
  ///
1127 1183
  ///\sa NotWriteMap
1128 1184
  template <typename M> 
... ...
@@ -1141,10 +1197,10 @@
1141 1197

	
1142 1198
  ///Logical 'not' of a map (ReadWrie version)
1143 1199
  
1144
  ///This bool \c concepts::ReadWriteMap "read-write map" returns the 
1200
  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
1145 1201
  ///logical negation of the value returned by the given map. When it is set,
1146 1202
  ///the opposite value is set to the original map.
1147
  ///Its \c Key is inherited from \c M, its Value is \c bool.
1203
  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
1148 1204
  ///
1149 1205
  ///\sa NotMap
1150 1206
  template <typename M> 
... ...
@@ -1209,15 +1265,15 @@
1209 1265

	
1210 1266
  /// \brief Writable bool map for logging each \c true assigned element
1211 1267
  ///
1212
  /// Writable bool map for logging each \c true assigned element, i.e it
1213
  /// copies all the keys set to \c true to the given iterator.
1268
  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging 
1269
  /// each \c true assigned element, i.e it copies all the keys set 
1270
  /// to \c true to the given iterator.
1214 1271
  ///
1215 1272
  /// \note The container of the iterator should contain space 
1216 1273
  /// for each element.
1217 1274
  ///
1218
  /// The following example shows how you can write the edges found by the Prim
1219
  /// algorithm directly
1220
  /// to the standard output.
1275
  /// The following example shows how you can write the edges found by 
1276
  /// the \ref Prim algorithm directly to the standard output.
1221 1277
  ///\code
1222 1278
  /// typedef IdMap<Graph, Edge> EdgeIdMap;
1223 1279
  /// EdgeIdMap edgeId(graph);
0 comments (0 inline)