xymap.h
author hegyi
Thu, 20 Oct 2005 15:50:23 +0000
branchgui
changeset 81 5ad61c33487c
child 98 f60f89147531
permissions -rw-r--r--
Mapselector widget reached its first release, but there are still work to do on it, I know...
ladanyi@53
     1
#ifndef XYMAP_H
ladanyi@53
     2
#define XYMAP_H
ladanyi@53
     3
ladanyi@53
     4
#include <lemon/list_graph.h>
ladanyi@53
     5
#include <lemon/xy.h>
ladanyi@53
     6
ladanyi@53
     7
using lemon::ListGraph;
ladanyi@53
     8
using lemon::xy;
ladanyi@53
     9
ladanyi@53
    10
template<class M>
ladanyi@53
    11
class XYMap
ladanyi@53
    12
{
ladanyi@53
    13
  private:
ladanyi@53
    14
    M *xmap, *ymap;
ladanyi@53
    15
ladanyi@53
    16
  public:
ladanyi@53
    17
    typedef typename M::Key Key;
ladanyi@53
    18
    typedef xy<typename M::Value> Value;
ladanyi@53
    19
    XYMap() {}
ladanyi@53
    20
    XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
ladanyi@53
    21
    void setXMap(M &_xmap) { xmap = &_xmap; }
ladanyi@53
    22
    void setYMap(M &_ymap) { ymap = &_ymap; }
ladanyi@53
    23
    Value operator[](Key k) const
ladanyi@53
    24
    {
ladanyi@53
    25
      Value v(xmap->operator[](k), ymap->operator[](k));
ladanyi@53
    26
      return v;
ladanyi@53
    27
    }
ladanyi@53
    28
    void set(Key k, Value v)
ladanyi@53
    29
    {
ladanyi@53
    30
      xmap->set(k, v.x);
ladanyi@53
    31
      ymap->set(k, v.y);
ladanyi@53
    32
    }
ladanyi@53
    33
};
ladanyi@53
    34
ladanyi@53
    35
#endif