gui/xymap.h
author marci
Sun, 13 Nov 2005 20:01:17 +0000
changeset 1787 932b8490caf0
child 1860 27a9a75b957b
permissions -rw-r--r--
bugfix in setCol, getting dual values
ladanyi@1606
     1
#ifndef XYMAP_H
ladanyi@1606
     2
#define XYMAP_H
ladanyi@1606
     3
ladanyi@1606
     4
#include <lemon/list_graph.h>
ladanyi@1606
     5
#include <lemon/xy.h>
ladanyi@1606
     6
ladanyi@1606
     7
using lemon::ListGraph;
ladanyi@1606
     8
using lemon::xy;
ladanyi@1606
     9
ladanyi@1606
    10
template<class M>
ladanyi@1606
    11
class XYMap
ladanyi@1606
    12
{
ladanyi@1606
    13
  private:
ladanyi@1606
    14
    M *xmap, *ymap;
ladanyi@1606
    15
ladanyi@1606
    16
  public:
ladanyi@1606
    17
    typedef typename M::Key Key;
ladanyi@1606
    18
    typedef xy<typename M::Value> Value;
ladanyi@1606
    19
    XYMap() {}
ladanyi@1606
    20
    XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
ladanyi@1606
    21
    void setXMap(M &_xmap) { xmap = &_xmap; }
ladanyi@1606
    22
    void setYMap(M &_ymap) { ymap = &_ymap; }
ladanyi@1606
    23
    Value operator[](Key k) const
ladanyi@1606
    24
    {
ladanyi@1606
    25
      Value v(xmap->operator[](k), ymap->operator[](k));
ladanyi@1606
    26
      return v;
ladanyi@1606
    27
    }
ladanyi@1606
    28
    void set(Key k, Value v)
ladanyi@1606
    29
    {
ladanyi@1606
    30
      xmap->set(k, v.x);
ladanyi@1606
    31
      ymap->set(k, v.y);
ladanyi@1606
    32
    }
ladanyi@1606
    33
};
ladanyi@1606
    34
ladanyi@1606
    35
#endif