xymap.h
changeset 1 67188bd752db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xymap.h	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* -*- C++ -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library
     1.7 + *
     1.8 + * Copyright (C) 2003-2006
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifndef XYMAP_H
    1.23 +#define XYMAP_H
    1.24 +
    1.25 +#include <lemon/list_graph.h>
    1.26 +#include <lemon/dim2.h>
    1.27 +
    1.28 +template<class M>
    1.29 +class XYMap
    1.30 +{
    1.31 +  private:
    1.32 +    M *xmap, *ymap;
    1.33 +
    1.34 +  public:
    1.35 +    typedef typename M::Key Key;
    1.36 +    typedef lemon::dim2::Point<typename M::Value> Value;
    1.37 +    XYMap() {}
    1.38 +    XYMap(M &_xmap, M &_ymap) : xmap(&_xmap), ymap(&_ymap) {}
    1.39 +    void setXMap(M &_xmap) { xmap = &_xmap; }
    1.40 +    void setYMap(M &_ymap) { ymap = &_ymap; }
    1.41 +    Value operator[](Key k) const
    1.42 +    {
    1.43 +      Value v(xmap->operator[](k), ymap->operator[](k));
    1.44 +      return v;
    1.45 +    }
    1.46 +    void set(Key k, Value v)
    1.47 +    {
    1.48 +      xmap->set(k, v.x);
    1.49 +      ymap->set(k, v.y);
    1.50 +    }
    1.51 +};
    1.52 +
    1.53 +#endif