Changeset 1044:f97380557656 in lemon0.x
 Timestamp:
 01/04/05 18:05:20 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1438
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/maps.h
r1041 r1044 197 197 /// 198 198 AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 199 Value operator[](Key k) {return m1[k]+m2[k];}199 Value operator[](Key k) const {return m1[k]+m2[k];} 200 200 }; 201 201 … … 234 234 /// 235 235 SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 236 Value operator[](Key k) {return m1[k]m2[k];}236 Value operator[](Key k) const {return m1[k]m2[k];} 237 237 }; 238 238 … … 270 270 /// 271 271 MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 272 Value operator[](Key k) {return m1[k]*m2[k];}272 Value operator[](Key k) const {return m1[k]*m2[k];} 273 273 }; 274 274 … … 304 304 /// 305 305 DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 306 Value operator[](Key k) {return m1[k]/m2[k];}306 Value operator[](Key k) const {return m1[k]/m2[k];} 307 307 }; 308 308 … … 327 327 /// ComposeMap<M1,M2> cm(m1,m2); 328 328 ///\endcode 329 /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>329 /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt> 330 330 /// 331 331 ///Its \c Key is inherited from \c M2 and its \c Value is from … … 348 348 /// 349 349 ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 350 Value operator[](Key k) {return m1[m2[k]];}350 Value operator[](Key k) const {return m1[m2[k]];} 351 351 }; 352 352 … … 382 382 /// 383 383 NegMap(const M &_m) : m(_m) {}; 384 Value operator[](Key k) {return m[k];}384 Value operator[](Key k) const {return m[k];} 385 385 }; 386 386 … … 396 396 397 397 398 //\todo We need a unified way to handle the situation below!399 struct _UnConvertible {};400 template<class A> inline A t_abs(A a) {return _UnConvertible();}401 402 template<> inline int t_abs<>(int n) {return abs(n);}403 template<> inline long int t_abs<>(long int n) {return labs(n);}404 //\bug llabs() is overloaded405 template<> inline long long int t_abs<>(long long int n) {return ::llabs(n);}406 407 template<> inline float t_abs<>(float n) {return fabsf(n);}408 template<> inline double t_abs<>(double n) {return fabs(n);}409 template<> inline long double t_abs<>(long double n) {return fabsl(n);}410 411 398 ///Absolute value of a map 412 399 … … 414 401 ///of the 415 402 ///value returned by the 416 ///given map. Its \c Key and \c Value will be inherited from \c M. 417 ///The function <tt>Value abs(Value)<tt> must be defined, of course. 403 ///given map. Its \c Key and \c Value will be inherited 404 ///from <tt>M</tt>. <tt>Value</tt> 405 ///must be comparable to <tt>0</tt> and the unary <tt></tt> 406 ///operator must be defined for it, of course. 407 /// 408 ///\bug We need a unified way to handle the situation below: 409 ///\code 410 /// struct _UnConvertible {}; 411 /// template<class A> inline A t_abs(A a) {return _UnConvertible();} 412 /// template<> inline int t_abs<>(int n) {return abs(n);} 413 /// template<> inline long int t_abs<>(long int n) {return labs(n);} 414 /// template<> inline long long int t_abs<>(long long int n) {return ::llabs(n);} 415 /// template<> inline float t_abs<>(float n) {return fabsf(n);} 416 /// template<> inline double t_abs<>(double n) {return fabs(n);} 417 /// template<> inline long double t_abs<>(long double n) {return fabsl(n);} 418 ///\endcode 419 418 420 419 421 template<class M> … … 430 432 /// 431 433 AbsMap(const M &_m) : m(_m) {}; 432 Value operator[](Key k) {return t_abs(m[k]);}434 Value operator[](Key k) const {Value tmp=m[k]; return tmp>=0?tmp:tmp;} 433 435 }; 434 436
Note: See TracChangeset
for help on using the changeset viewer.