gui/xymap.h
changeset 1666 30d7e673781f
child 1860 27a9a75b957b
equal deleted inserted replaced
-1:000000000000 0:fd2c26d0071b
       
     1 #ifndef XYMAP_H
       
     2 #define XYMAP_H
       
     3 
       
     4 #include <lemon/list_graph.h>
       
     5 #include <lemon/xy.h>
       
     6 
       
     7 using lemon::ListGraph;
       
     8 using lemon::xy;
       
     9 
       
    10 template<class M>
       
    11 class XYMap
       
    12 {
       
    13   private:
       
    14     M *xmap, *ymap;
       
    15 
       
    16   public:
       
    17     typedef typename M::Key Key;
       
    18     typedef xy<typename M::Value> Value;
       
    19     XYMap() {}
       
    20     XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
       
    21     void setXMap(M &_xmap) { xmap = &_xmap; }
       
    22     void setYMap(M &_ymap) { ymap = &_ymap; }
       
    23     Value operator[](Key k) const
       
    24     {
       
    25       Value v(xmap->operator[](k), ymap->operator[](k));
       
    26       return v;
       
    27     }
       
    28     void set(Key k, Value v)
       
    29     {
       
    30       xmap->set(k, v.x);
       
    31       ymap->set(k, v.y);
       
    32     }
       
    33 };
       
    34 
       
    35 #endif