Add basic logical maps and doc improvements
authorPeter Kovacs <kpeter@inf.elte.hu>
Sat, 15 Mar 2008 23:39:41 +0100
changeset 82bce6c8f93d10
parent 81 7ff1c348ae0c
child 83 3654324ec035
Add basic logical maps and doc improvements

- Add the following new logical maps and map adaptors:
* TrueMap, FalseMap
* AndMap, OrMap
* EqualMap, LessMap
- Improve the documentation for other classes.
lemon/maps.h
test/maps_test.cc
     1.1 --- a/lemon/maps.h	Sat Mar 15 21:24:43 2008 +0100
     1.2 +++ b/lemon/maps.h	Sat Mar 15 23:39:41 2008 +0100
     1.3 @@ -86,8 +86,8 @@
     1.4  
     1.5    /// Constant map.
     1.6  
     1.7 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a
     1.8 -  /// specified value to each key.
     1.9 +  /// This \ref concepts::ReadMap "readable map" assigns a specified
    1.10 +  /// value to each key.
    1.11    ///
    1.12    /// In other aspects it is equivalent to \ref NullMap.
    1.13    /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
    1.14 @@ -149,8 +149,8 @@
    1.15  
    1.16    /// Constant map with inlined constant value.
    1.17  
    1.18 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a
    1.19 -  /// specified value to each key.
    1.20 +  /// This \ref concepts::ReadMap "readable map" assigns a specified
    1.21 +  /// value to each key.
    1.22    ///
    1.23    /// In other aspects it is equivalent to \ref NullMap.
    1.24    /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
    1.25 @@ -189,10 +189,10 @@
    1.26    }
    1.27  
    1.28  
    1.29 -  /// \brief Identity map.
    1.30 -  ///
    1.31 -  /// This map gives back the given key as value without any
    1.32 -  /// modification.
    1.33 +  /// Identity map.
    1.34 +
    1.35 +  /// This \ref concepts::ReadMap "read-only map" gives back the given
    1.36 +  /// key as value without any modification.
    1.37    ///
    1.38    /// \sa ConstMap
    1.39    template <typename T>
    1.40 @@ -203,8 +203,8 @@
    1.41      typedef typename Parent::Value Value;
    1.42  
    1.43      /// Gives back the given value without any modification.
    1.44 -    const T& operator[](const T& t) const {
    1.45 -      return t;
    1.46 +    Value operator[](const Key &k) const {
    1.47 +      return k;
    1.48      }
    1.49    };
    1.50  
    1.51 @@ -464,7 +464,7 @@
    1.52  
    1.53    /// Composition of two maps
    1.54  
    1.55 -  /// This \ref concepts::ReadMap "read only map" returns the
    1.56 +  /// This \ref concepts::ReadMap "read-only map" returns the
    1.57    /// composition of two given maps. That is to say, if \c m1 is of
    1.58    /// type \c M1 and \c m2 is of \c M2, then for
    1.59    /// \code
    1.60 @@ -516,7 +516,7 @@
    1.61  
    1.62    /// Combination of two maps using an STL (binary) functor.
    1.63  
    1.64 -  /// This \ref concepts::ReadMap "read only map" takes two maps and a
    1.65 +  /// This \ref concepts::ReadMap "read-only map" takes two maps and a
    1.66    /// binary functor and returns the combination of the two given maps
    1.67    /// using the functor.
    1.68    /// That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2
    1.69 @@ -595,7 +595,7 @@
    1.70  
    1.71    /// Converts an STL style (unary) functor to a map
    1.72  
    1.73 -  /// This \ref concepts::ReadMap "read only map" returns the value
    1.74 +  /// This \ref concepts::ReadMap "read-only map" returns the value
    1.75    /// of a given functor. Actually, it just wraps the functor and
    1.76    /// provides the \c Key and \c Value typedefs.
    1.77    ///
    1.78 @@ -775,7 +775,7 @@
    1.79  
    1.80    /// Sum of two maps
    1.81  
    1.82 -  /// This \ref concepts::ReadMap "read only map" returns the sum
    1.83 +  /// This \ref concepts::ReadMap "read-only map" returns the sum
    1.84    /// of the values of the two given maps.
    1.85    /// Its \c Key and \c Value types are inherited from \c M1.
    1.86    /// The \c Key and \c Value of \c M2 must be convertible to those of
    1.87 @@ -824,7 +824,7 @@
    1.88  
    1.89    /// Difference of two maps
    1.90  
    1.91 -  /// This \ref concepts::ReadMap "read only map" returns the difference
    1.92 +  /// This \ref concepts::ReadMap "read-only map" returns the difference
    1.93    /// of the values of the two given maps.
    1.94    /// Its \c Key and \c Value types are inherited from \c M1.
    1.95    /// The \c Key and \c Value of \c M2 must be convertible to those of
    1.96 @@ -872,7 +872,7 @@
    1.97  
    1.98    /// Product of two maps
    1.99  
   1.100 -  /// This \ref concepts::ReadMap "read only map" returns the product
   1.101 +  /// This \ref concepts::ReadMap "read-only map" returns the product
   1.102    /// of the values of the two given maps.
   1.103    /// Its \c Key and \c Value types are inherited from \c M1.
   1.104    /// The \c Key and \c Value of \c M2 must be convertible to those of
   1.105 @@ -921,7 +921,7 @@
   1.106  
   1.107    /// Quotient of two maps
   1.108  
   1.109 -  /// This \ref concepts::ReadMap "read only map" returns the quotient
   1.110 +  /// This \ref concepts::ReadMap "read-only map" returns the quotient
   1.111    /// of the values of the two given maps.
   1.112    /// Its \c Key and \c Value types are inherited from \c M1.
   1.113    /// The \c Key and \c Value of \c M2 must be convertible to those of
   1.114 @@ -969,7 +969,7 @@
   1.115  
   1.116    /// Shifts a map with a constant.
   1.117  
   1.118 -  /// This \ref concepts::ReadMap "read only map" returns the sum of
   1.119 +  /// This \ref concepts::ReadMap "read-only map" returns the sum of
   1.120    /// the given map and a constant value (i.e. it shifts the map with
   1.121    /// the constant). Its \c Key and \c Value are inherited from \c M.
   1.122    ///
   1.123 @@ -1070,7 +1070,7 @@
   1.124  
   1.125    /// Scales a map with a constant.
   1.126  
   1.127 -  /// This \ref concepts::ReadMap "read only map" returns the value of
   1.128 +  /// This \ref concepts::ReadMap "read-only map" returns the value of
   1.129    /// the given map multiplied from the left side with a constant value.
   1.130    /// Its \c Key and \c Value are inherited from \c M.
   1.131    ///
   1.132 @@ -1172,7 +1172,7 @@
   1.133  
   1.134    /// Negative of a map
   1.135  
   1.136 -  /// This \ref concepts::ReadMap "read only map" returns the negative
   1.137 +  /// This \ref concepts::ReadMap "read-only map" returns the negative
   1.138    /// of the values of the given map (using the unary \c - operator).
   1.139    /// Its \c Key and \c Value are inherited from \c M.
   1.140    ///
   1.141 @@ -1270,7 +1270,7 @@
   1.142  
   1.143    /// Absolute value of a map
   1.144  
   1.145 -  /// This \ref concepts::ReadMap "read only map" returns the absolute
   1.146 +  /// This \ref concepts::ReadMap "read-only map" returns the absolute
   1.147    /// value of the values of the given map.
   1.148    /// Its \c Key and \c Value are inherited from \c M.
   1.149    /// \c Value must be comparable to \c 0 and the unary \c -
   1.150 @@ -1311,10 +1311,190 @@
   1.151      return AbsMap<M>(m);
   1.152    }
   1.153  
   1.154 +  /// @}
   1.155 +  
   1.156 +  // Logical maps and map adaptors:
   1.157 +
   1.158 +  /// \addtogroup maps
   1.159 +  /// @{
   1.160 +
   1.161 +  /// Constant \c true map.
   1.162 +
   1.163 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
   1.164 +  /// each key.
   1.165 +  ///
   1.166 +  /// Note that
   1.167 +  /// \code
   1.168 +  ///   TrueMap<K> tm;
   1.169 +  /// \endcode
   1.170 +  /// is equivalent to
   1.171 +  /// \code
   1.172 +  ///   ConstMap<K,bool> tm(true);
   1.173 +  /// \endcode
   1.174 +  ///
   1.175 +  /// \sa FalseMap
   1.176 +  /// \sa ConstMap
   1.177 +  template <typename K>
   1.178 +  class TrueMap : public MapBase<K, bool> {
   1.179 +  public:
   1.180 +    typedef MapBase<K, bool> Parent;
   1.181 +    typedef typename Parent::Key Key;
   1.182 +    typedef typename Parent::Value Value;
   1.183 +
   1.184 +    /// Gives back \c true.
   1.185 +    Value operator[](const Key&) const { return true; }
   1.186 +  };
   1.187 +
   1.188 +  /// Returns a \ref TrueMap class
   1.189 +
   1.190 +  /// This function just returns a \ref TrueMap class.
   1.191 +  /// \relates TrueMap
   1.192 +  template<typename K>
   1.193 +  inline TrueMap<K> trueMap() {
   1.194 +    return TrueMap<K>();
   1.195 +  }
   1.196 +
   1.197 +
   1.198 +  /// Constant \c false map.
   1.199 +
   1.200 +  /// This \ref concepts::ReadMap "read-only map" assigns \c false to
   1.201 +  /// each key.
   1.202 +  ///
   1.203 +  /// Note that
   1.204 +  /// \code
   1.205 +  ///   FalseMap<K> fm;
   1.206 +  /// \endcode
   1.207 +  /// is equivalent to
   1.208 +  /// \code
   1.209 +  ///   ConstMap<K,bool> fm(false);
   1.210 +  /// \endcode
   1.211 +  ///
   1.212 +  /// \sa TrueMap
   1.213 +  /// \sa ConstMap
   1.214 +  template <typename K>
   1.215 +  class FalseMap : public MapBase<K, bool> {
   1.216 +  public:
   1.217 +    typedef MapBase<K, bool> Parent;
   1.218 +    typedef typename Parent::Key Key;
   1.219 +    typedef typename Parent::Value Value;
   1.220 +
   1.221 +    /// Gives back \c false.
   1.222 +    Value operator[](const Key&) const { return false; }
   1.223 +  };
   1.224 +
   1.225 +  /// Returns a \ref FalseMap class
   1.226 +
   1.227 +  /// This function just returns a \ref FalseMap class.
   1.228 +  /// \relates FalseMap
   1.229 +  template<typename K>
   1.230 +  inline FalseMap<K> falseMap() {
   1.231 +    return FalseMap<K>();
   1.232 +  }
   1.233 +
   1.234 +  /// @}
   1.235 +
   1.236 +  /// \addtogroup map_adaptors
   1.237 +  /// @{
   1.238 +
   1.239 +  /// Logical 'and' of two maps
   1.240 +
   1.241 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
   1.242 +  /// 'and' of the values of the two given maps.
   1.243 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
   1.244 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
   1.245 +  ///
   1.246 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
   1.247 +  /// \code
   1.248 +  ///   AndMap<M1,M2> am(m1,m2);
   1.249 +  /// \endcode
   1.250 +  /// <tt>am[x]</tt> will be equal to <tt>m1[x]&&m2[x]</tt>.
   1.251 +  ///
   1.252 +  /// The simplest way of using this map is through the andMap()
   1.253 +  /// function.
   1.254 +  ///
   1.255 +  /// \sa OrMap
   1.256 +  /// \sa NotMap, NotWriteMap
   1.257 +  template<typename M1, typename M2>
   1.258 +  class AndMap : public MapBase<typename M1::Key, bool> {
   1.259 +    const M1 &_m1;
   1.260 +    const M2 &_m2;
   1.261 +  public:
   1.262 +    typedef MapBase<typename M1::Key, bool> Parent;
   1.263 +    typedef typename Parent::Key Key;
   1.264 +    typedef typename Parent::Value Value;
   1.265 +
   1.266 +    /// Constructor
   1.267 +    AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   1.268 +    /// \e
   1.269 +    Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; }
   1.270 +  };
   1.271 +
   1.272 +  /// Returns an \ref AndMap class
   1.273 +
   1.274 +  /// This function just returns an \ref AndMap class.
   1.275 +  ///
   1.276 +  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
   1.277 +  /// then <tt>andMap(m1,m2)[x]</tt> will be equal to
   1.278 +  /// <tt>m1[x]&&m2[x]</tt>.
   1.279 +  ///
   1.280 +  /// \relates AndMap
   1.281 +  template<typename M1, typename M2>
   1.282 +  inline AndMap<M1, M2> andMap(const M1 &m1, const M2 &m2) {
   1.283 +    return AndMap<M1, M2>(m1,m2);
   1.284 +  }
   1.285 +
   1.286 +
   1.287 +  /// Logical 'or' of two maps
   1.288 +
   1.289 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
   1.290 +  /// 'or' of the values of the two given maps.
   1.291 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
   1.292 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
   1.293 +  ///
   1.294 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
   1.295 +  /// \code
   1.296 +  ///   OrMap<M1,M2> om(m1,m2);
   1.297 +  /// \endcode
   1.298 +  /// <tt>om[x]</tt> will be equal to <tt>m1[x]||m2[x]</tt>.
   1.299 +  ///
   1.300 +  /// The simplest way of using this map is through the orMap()
   1.301 +  /// function.
   1.302 +  ///
   1.303 +  /// \sa AndMap
   1.304 +  /// \sa NotMap, NotWriteMap
   1.305 +  template<typename M1, typename M2>
   1.306 +  class OrMap : public MapBase<typename M1::Key, bool> {
   1.307 +    const M1 &_m1;
   1.308 +    const M2 &_m2;
   1.309 +  public:
   1.310 +    typedef MapBase<typename M1::Key, bool> Parent;
   1.311 +    typedef typename Parent::Key Key;
   1.312 +    typedef typename Parent::Value Value;
   1.313 +
   1.314 +    /// Constructor
   1.315 +    OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   1.316 +    /// \e
   1.317 +    Value operator[](const Key &k) const { return _m1[k]||_m2[k]; }
   1.318 +  };
   1.319 +
   1.320 +  /// Returns an \ref OrMap class
   1.321 +
   1.322 +  /// This function just returns an \ref OrMap class.
   1.323 +  ///
   1.324 +  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
   1.325 +  /// then <tt>orMap(m1,m2)[x]</tt> will be equal to
   1.326 +  /// <tt>m1[x]||m2[x]</tt>.
   1.327 +  ///
   1.328 +  /// \relates OrMap
   1.329 +  template<typename M1, typename M2>
   1.330 +  inline OrMap<M1, M2> orMap(const M1 &m1, const M2 &m2) {
   1.331 +    return OrMap<M1, M2>(m1,m2);
   1.332 +  }
   1.333 +
   1.334  
   1.335    /// Logical 'not' of a map
   1.336  
   1.337 -  /// This \ref concepts::ReadMap "read only map" returns the logical
   1.338 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
   1.339    /// negation of the values of the given map.
   1.340    /// Its \c Key is inherited from \c M and its \c Value is \c bool.
   1.341    ///
   1.342 @@ -1391,6 +1571,102 @@
   1.343      return NotWriteMap<M>(m);
   1.344    }
   1.345  
   1.346 +
   1.347 +  /// Combination of two maps using the \c == operator
   1.348 +
   1.349 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
   1.350 +  /// the keys for which the corresponding values of the two maps are
   1.351 +  /// equal.
   1.352 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
   1.353 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
   1.354 +  ///
   1.355 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
   1.356 +  /// \code
   1.357 +  ///   EqualMap<M1,M2> em(m1,m2);
   1.358 +  /// \endcode
   1.359 +  /// <tt>em[x]</tt> will be equal to <tt>m1[x]==m2[x]</tt>.
   1.360 +  ///
   1.361 +  /// The simplest way of using this map is through the equalMap()
   1.362 +  /// function.
   1.363 +  ///
   1.364 +  /// \sa LessMap
   1.365 +  template<typename M1, typename M2>
   1.366 +  class EqualMap : public MapBase<typename M1::Key, bool> {
   1.367 +    const M1 &_m1;
   1.368 +    const M2 &_m2;
   1.369 +  public:
   1.370 +    typedef MapBase<typename M1::Key, bool> Parent;
   1.371 +    typedef typename Parent::Key Key;
   1.372 +    typedef typename Parent::Value Value;
   1.373 +
   1.374 +    /// Constructor
   1.375 +    EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   1.376 +    /// \e
   1.377 +    Value operator[](const Key &k) const { return _m1[k]==_m2[k]; }
   1.378 +  };
   1.379 +
   1.380 +  /// Returns an \ref EqualMap class
   1.381 +
   1.382 +  /// This function just returns an \ref EqualMap class.
   1.383 +  ///
   1.384 +  /// For example, if \c m1 and \c m2 are maps with keys and values of
   1.385 +  /// the same type, then <tt>equalMap(m1,m2)[x]</tt> will be equal to
   1.386 +  /// <tt>m1[x]==m2[x]</tt>.
   1.387 +  ///
   1.388 +  /// \relates EqualMap
   1.389 +  template<typename M1, typename M2>
   1.390 +  inline EqualMap<M1, M2> equalMap(const M1 &m1, const M2 &m2) {
   1.391 +    return EqualMap<M1, M2>(m1,m2);
   1.392 +  }
   1.393 +
   1.394 +
   1.395 +  /// Combination of two maps using the \c < operator
   1.396 +
   1.397 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
   1.398 +  /// the keys for which the corresponding value of the first map is
   1.399 +  /// less then the value of the second map.
   1.400 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
   1.401 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
   1.402 +  ///
   1.403 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
   1.404 +  /// \code
   1.405 +  ///   LessMap<M1,M2> lm(m1,m2);
   1.406 +  /// \endcode
   1.407 +  /// <tt>lm[x]</tt> will be equal to <tt>m1[x]<m2[x]</tt>.
   1.408 +  ///
   1.409 +  /// The simplest way of using this map is through the lessMap()
   1.410 +  /// function.
   1.411 +  ///
   1.412 +  /// \sa EqualMap
   1.413 +  template<typename M1, typename M2>
   1.414 +  class LessMap : public MapBase<typename M1::Key, bool> {
   1.415 +    const M1 &_m1;
   1.416 +    const M2 &_m2;
   1.417 +  public:
   1.418 +    typedef MapBase<typename M1::Key, bool> Parent;
   1.419 +    typedef typename Parent::Key Key;
   1.420 +    typedef typename Parent::Value Value;
   1.421 +
   1.422 +    /// Constructor
   1.423 +    LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   1.424 +    /// \e
   1.425 +    Value operator[](const Key &k) const { return _m1[k]<_m2[k]; }
   1.426 +  };
   1.427 +
   1.428 +  /// Returns an \ref LessMap class
   1.429 +
   1.430 +  /// This function just returns an \ref LessMap class.
   1.431 +  ///
   1.432 +  /// For example, if \c m1 and \c m2 are maps with keys and values of
   1.433 +  /// the same type, then <tt>lessMap(m1,m2)[x]</tt> will be equal to
   1.434 +  /// <tt>m1[x]<m2[x]</tt>.
   1.435 +  ///
   1.436 +  /// \relates LessMap
   1.437 +  template<typename M1, typename M2>
   1.438 +  inline LessMap<M1, M2> lessMap(const M1 &m1, const M2 &m2) {
   1.439 +    return LessMap<M1, M2>(m1,m2);
   1.440 +  }
   1.441 +
   1.442    /// @}
   1.443  }
   1.444  
     2.1 --- a/test/maps_test.cc	Sat Mar 15 21:24:43 2008 +0100
     2.2 +++ b/test/maps_test.cc	Sat Mar 15 23:39:41 2008 +0100
     2.3 @@ -78,7 +78,7 @@
     2.4      ConstMap<A,B> map3 = map1;
     2.5      map1 = constMap<A>(B());
     2.6      map1.setAll(B());
     2.7 -    
     2.8 +
     2.9      checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
    2.10      check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
    2.11  
    2.12 @@ -95,7 +95,7 @@
    2.13      IdentityMap<A> map1;
    2.14      IdentityMap<A> map2 = map1;
    2.15      map1 = identityMap<A>();
    2.16 -    
    2.17 +
    2.18      checkConcept<ReadMap<double,double>, IdentityMap<double> >();
    2.19      check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14,
    2.20            "Something is wrong with IdentityMap");
    2.21 @@ -151,7 +151,7 @@
    2.22      checkConcept<ReadMap<B,double>, CompMap>();
    2.23      CompMap map1(DoubleMap(),ReadMap<B,A>());
    2.24      CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
    2.25 -    
    2.26 +
    2.27      SparseMap<double, bool> m1(false); m1[3.14] = true;
    2.28      RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
    2.29      check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], "Something is wrong with ComposeMap")
    2.30 @@ -197,7 +197,7 @@
    2.31    // ForkMap
    2.32    {
    2.33      checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
    2.34 -    
    2.35 +
    2.36      typedef RangeMap<double> RM;
    2.37      typedef SparseMap<int, double> SM;
    2.38      RM m1(10, -1);
    2.39 @@ -210,7 +210,7 @@
    2.40      check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
    2.41            "Something is wrong with ForkMap");
    2.42    }
    2.43 -  
    2.44 +
    2.45    // Arithmetic maps:
    2.46    // - AddMap, SubMap, MulMap, DivMap
    2.47    // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
    2.48 @@ -220,7 +220,7 @@
    2.49      checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
    2.50      checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
    2.51      checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
    2.52 -    
    2.53 +
    2.54      ConstMap<int, double> c1(1.0), c2(3.14);
    2.55      IdentityMap<int> im;
    2.56      ConvertMap<IdentityMap<int>, double> id(im);
    2.57 @@ -228,7 +228,7 @@
    2.58      check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,  "Something is wrong with SubMap");
    2.59      check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28, "Something is wrong with MulMap");
    2.60      check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57, "Something is wrong with DivMap");
    2.61 -    
    2.62 +
    2.63      checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
    2.64      checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
    2.65      checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
    2.66 @@ -252,16 +252,40 @@
    2.67      check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
    2.68            "Something is wrong with AbsMap");
    2.69    }
    2.70 -  
    2.71 -  // Logical maps
    2.72 +
    2.73 +  // Logical maps:
    2.74 +  // - TrueMap, FalseMap
    2.75 +  // - AndMap, OrMap
    2.76 +  // - NotMap, NotWriteMap
    2.77 +  // - EqualMap, LessMap
    2.78    {
    2.79 +    checkConcept<BoolMap, TrueMap<A> >();
    2.80 +    checkConcept<BoolMap, FalseMap<A> >();
    2.81 +    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
    2.82 +    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
    2.83      checkConcept<BoolMap, NotMap<BoolMap> >();
    2.84      checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
    2.85 -    
    2.86 +    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
    2.87 +    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
    2.88 +
    2.89 +    TrueMap<int> tm;
    2.90 +    FalseMap<int> fm;
    2.91      RangeMap<bool> rm(2);
    2.92      rm[0] = true; rm[1] = false;
    2.93 -    check(!(notMap(rm)[0]) && notMap(rm)[1], "Something is wrong with NotMap");
    2.94 -    check(!(notWriteMap(rm)[0]) && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
    2.95 +    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
    2.96 +          "Something is wrong with AndMap");
    2.97 +    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1],
    2.98 +          "Something is wrong with OrMap");
    2.99 +    check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap");
   2.100 +    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
   2.101 +
   2.102 +    ConstMap<int, double> cm(2.0);
   2.103 +    IdentityMap<int> im;
   2.104 +    ConvertMap<IdentityMap<int>, double> id(im);
   2.105 +    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
   2.106 +          "Something is wrong with LessMap");
   2.107 +    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
   2.108 +          "Something is wrong with EqualMap");
   2.109    }
   2.110  
   2.111    return 0;