lemon/dim2.h
changeset 317 64f8f7cc6168
parent 253 dbe309b5e855
child 318 2cc60866a0c9
equal deleted inserted replaced
9:6f3cb84bd930 10:9caacd180178
   257     return Point<T>(z.y,-z.x);
   257     return Point<T>(z.y,-z.x);
   258   }
   258   }
   259 
   259 
   260 
   260 
   261 
   261 
   262   /// Bounding box of plain vectors (\ref Point points).
   262   /// Bounding box of plain vectors (points).
   263 
   263 
   264   /// A class to calculate or store the bounding box of plain vectors
   264   /// A class to calculate or store the bounding box of plain vectors
   265   /// (\ref Point points).
   265   /// (\ref Point "points").
   266   template<typename T>
   266   template<typename T>
   267   class Box {
   267   class Box {
   268       Point<T> _bottom_left, _top_right;
   268       Point<T> _bottom_left, _top_right;
   269       bool _empty;
   269       bool _empty;
   270     public:
   270     public:
   571   {
   571   {
   572     os << "(" << b.bottomLeft() << "," << b.topRight() << ")";
   572     os << "(" << b.bottomLeft() << "," << b.topRight() << ")";
   573     return os;
   573     return os;
   574   }
   574   }
   575 
   575 
   576   ///Map of x-coordinates of a \ref Point "Point"-map
   576   ///Map of x-coordinates of a <tt>Point</tt>-map
   577 
   577 
   578   ///\ingroup maps
       
   579   ///Map of x-coordinates of a \ref Point "Point"-map.
   578   ///Map of x-coordinates of a \ref Point "Point"-map.
   580   ///
   579   ///\ingroup maps
   581   template<class M>
   580   template<class M>
   582   class XMap
   581   class XMap
   583   {
   582   {
   584     M& _map;
   583     M& _map;
   585   public:
   584   public:
   590     XMap(M& map) : _map(map) {}
   589     XMap(M& map) : _map(map) {}
   591     Value operator[](Key k) const {return _map[k].x;}
   590     Value operator[](Key k) const {return _map[k].x;}
   592     void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   591     void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   593   };
   592   };
   594 
   593 
   595   ///Returns an \ref XMap class
   594   ///Returns an XMap class
   596 
   595 
   597   ///This function just returns an \ref XMap class.
   596   ///This function just returns an XMap class.
   598   ///
   597   ///
   599   ///\ingroup maps
   598   ///\ingroup maps
   600   ///\relates XMap
   599   ///\relates XMap
   601   template<class M>
   600   template<class M>
   602   inline XMap<M> xMap(M &m)
   601   inline XMap<M> xMap(M &m)
   608   inline XMap<M> xMap(const M &m)
   607   inline XMap<M> xMap(const M &m)
   609   {
   608   {
   610     return XMap<M>(m);
   609     return XMap<M>(m);
   611   }
   610   }
   612 
   611 
   613   ///Constant (read only) version of \ref XMap
   612   ///Constant (read only) version of XMap
   614 
   613 
   615   ///\ingroup maps
   614   ///Constant (read only) version of XMap.
   616   ///Constant (read only) version of \ref XMap
   615   ///\ingroup maps
   617   ///
       
   618   template<class M>
   616   template<class M>
   619   class ConstXMap
   617   class ConstXMap
   620   {
   618   {
   621     const M& _map;
   619     const M& _map;
   622   public:
   620   public:
   626     ///\e
   624     ///\e
   627     ConstXMap(const M &map) : _map(map) {}
   625     ConstXMap(const M &map) : _map(map) {}
   628     Value operator[](Key k) const {return _map[k].x;}
   626     Value operator[](Key k) const {return _map[k].x;}
   629   };
   627   };
   630 
   628 
   631   ///Returns a \ref ConstXMap class
   629   ///Returns a ConstXMap class
   632 
   630 
   633   ///This function just returns a \ref ConstXMap class.
   631   ///This function just returns a ConstXMap class.
   634   ///
   632   ///
   635   ///\ingroup maps
   633   ///\ingroup maps
   636   ///\relates ConstXMap
   634   ///\relates ConstXMap
   637   template<class M>
   635   template<class M>
   638   inline ConstXMap<M> xMap(const M &m)
   636   inline ConstXMap<M> xMap(const M &m)
   639   {
   637   {
   640     return ConstXMap<M>(m);
   638     return ConstXMap<M>(m);
   641   }
   639   }
   642 
   640 
   643   ///Map of y-coordinates of a \ref Point "Point"-map
   641   ///Map of y-coordinates of a <tt>Point</tt>-map
   644 
   642 
   645   ///\ingroup maps
       
   646   ///Map of y-coordinates of a \ref Point "Point"-map.
   643   ///Map of y-coordinates of a \ref Point "Point"-map.
   647   ///
   644   ///\ingroup maps
   648   template<class M>
   645   template<class M>
   649   class YMap
   646   class YMap
   650   {
   647   {
   651     M& _map;
   648     M& _map;
   652   public:
   649   public:
   657     YMap(M& map) : _map(map) {}
   654     YMap(M& map) : _map(map) {}
   658     Value operator[](Key k) const {return _map[k].y;}
   655     Value operator[](Key k) const {return _map[k].y;}
   659     void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   656     void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   660   };
   657   };
   661 
   658 
   662   ///Returns a \ref YMap class
   659   ///Returns a YMap class
   663 
   660 
   664   ///This function just returns a \ref YMap class.
   661   ///This function just returns a YMap class.
   665   ///
   662   ///
   666   ///\ingroup maps
   663   ///\ingroup maps
   667   ///\relates YMap
   664   ///\relates YMap
   668   template<class M>
   665   template<class M>
   669   inline YMap<M> yMap(M &m)
   666   inline YMap<M> yMap(M &m)
   675   inline YMap<M> yMap(const M &m)
   672   inline YMap<M> yMap(const M &m)
   676   {
   673   {
   677     return YMap<M>(m);
   674     return YMap<M>(m);
   678   }
   675   }
   679 
   676 
   680   ///Constant (read only) version of \ref YMap
   677   ///Constant (read only) version of YMap
   681 
   678 
   682   ///\ingroup maps
   679   ///Constant (read only) version of YMap.
   683   ///Constant (read only) version of \ref YMap
   680   ///\ingroup maps
   684   ///
       
   685   template<class M>
   681   template<class M>
   686   class ConstYMap
   682   class ConstYMap
   687   {
   683   {
   688     const M& _map;
   684     const M& _map;
   689   public:
   685   public:
   693     ///\e
   689     ///\e
   694     ConstYMap(const M &map) : _map(map) {}
   690     ConstYMap(const M &map) : _map(map) {}
   695     Value operator[](Key k) const {return _map[k].y;}
   691     Value operator[](Key k) const {return _map[k].y;}
   696   };
   692   };
   697 
   693 
   698   ///Returns a \ref ConstYMap class
   694   ///Returns a ConstYMap class
   699 
   695 
   700   ///This function just returns a \ref ConstYMap class.
   696   ///This function just returns a ConstYMap class.
   701   ///
   697   ///
   702   ///\ingroup maps
   698   ///\ingroup maps
   703   ///\relates ConstYMap
   699   ///\relates ConstYMap
   704   template<class M>
   700   template<class M>
   705   inline ConstYMap<M> yMap(const M &m)
   701   inline ConstYMap<M> yMap(const M &m)
   706   {
   702   {
   707     return ConstYMap<M>(m);
   703     return ConstYMap<M>(m);
   708   }
   704   }
   709 
   705 
   710 
   706 
   711   ///\brief Map of the \ref Point::normSquare() "normSquare()"
   707   ///\brief Map of the normSquare() of a <tt>Point</tt>-map
   712   ///of a \ref Point "Point"-map
       
   713   ///
   708   ///
   714   ///Map of the \ref Point::normSquare() "normSquare()"
   709   ///Map of the \ref Point::normSquare() "normSquare()"
   715   ///of a \ref Point "Point"-map.
   710   ///of a \ref Point "Point"-map.
   716   ///\ingroup maps
   711   ///\ingroup maps
   717   template<class M>
   712   template<class M>
   725     ///\e
   720     ///\e
   726     NormSquareMap(const M &map) : _map(map) {}
   721     NormSquareMap(const M &map) : _map(map) {}
   727     Value operator[](Key k) const {return _map[k].normSquare();}
   722     Value operator[](Key k) const {return _map[k].normSquare();}
   728   };
   723   };
   729 
   724 
   730   ///Returns a \ref NormSquareMap class
   725   ///Returns a NormSquareMap class
   731 
   726 
   732   ///This function just returns a \ref NormSquareMap class.
   727   ///This function just returns a NormSquareMap class.
   733   ///
   728   ///
   734   ///\ingroup maps
   729   ///\ingroup maps
   735   ///\relates NormSquareMap
   730   ///\relates NormSquareMap
   736   template<class M>
   731   template<class M>
   737   inline NormSquareMap<M> normSquareMap(const M &m)
   732   inline NormSquareMap<M> normSquareMap(const M &m)