xymap.h
author alpar
Mon, 30 Oct 2006 12:20:54 +0000
changeset 175 1e0a66d6b45a
parent 150 86273bfe0e4d
permissions -rw-r--r--
Add autopackage specfile (not yet working).
alpar@174
     1
/* -*- C++ -*-
alpar@174
     2
 *
alpar@174
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@174
     4
 *
alpar@174
     5
 * Copyright (C) 2003-2006
alpar@174
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@174
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@174
     8
 *
alpar@174
     9
 * Permission to use, modify and distribute this software is granted
alpar@174
    10
 * provided that this copyright notice appears in all copies. For
alpar@174
    11
 * precise terms see the accompanying LICENSE file.
alpar@174
    12
 *
alpar@174
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@174
    14
 * express or implied, and with no claim as to its suitability for any
alpar@174
    15
 * purpose.
alpar@174
    16
 *
alpar@174
    17
 */
alpar@174
    18
ladanyi@53
    19
#ifndef XYMAP_H
ladanyi@53
    20
#define XYMAP_H
ladanyi@53
    21
ladanyi@53
    22
#include <lemon/list_graph.h>
hegyi@150
    23
#include <lemon/dim2.h>
ladanyi@53
    24
ladanyi@53
    25
template<class M>
ladanyi@53
    26
class XYMap
ladanyi@53
    27
{
ladanyi@53
    28
  private:
ladanyi@53
    29
    M *xmap, *ymap;
ladanyi@53
    30
ladanyi@53
    31
  public:
ladanyi@53
    32
    typedef typename M::Key Key;
hegyi@150
    33
    typedef lemon::dim2::Point<typename M::Value> Value;
ladanyi@53
    34
    XYMap() {}
ladanyi@53
    35
    XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
ladanyi@53
    36
    void setXMap(M &_xmap) { xmap = &_xmap; }
ladanyi@53
    37
    void setYMap(M &_ymap) { ymap = &_ymap; }
ladanyi@53
    38
    Value operator[](Key k) const
ladanyi@53
    39
    {
ladanyi@53
    40
      Value v(xmap->operator[](k), ymap->operator[](k));
ladanyi@53
    41
      return v;
ladanyi@53
    42
    }
ladanyi@53
    43
    void set(Key k, Value v)
ladanyi@53
    44
    {
ladanyi@53
    45
      xmap->set(k, v.x);
ladanyi@53
    46
      ymap->set(k, v.y);
ladanyi@53
    47
    }
ladanyi@53
    48
};
ladanyi@53
    49
ladanyi@53
    50
#endif