src/work/alpar/rw_nonref_map.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/alpar/rw_nonref_map.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,97 +0,0 @@
     1.4 -#include <iostream>
     1.5 -#include <smart_graph.h>
     1.6 -
     1.7 -using namespace lemon;
     1.8 -
     1.9 -template<class GG,class TT>
    1.10 -class CinCoutMap
    1.11 -{
    1.12 -public:
    1.13 -  typedef GG Graph;
    1.14 -  typedef typename GG::Edge Edge;
    1.15 -  
    1.16 -  typedef Edge Key;
    1.17 -  typedef TT Value;
    1.18 -  
    1.19 -  class RefType 
    1.20 -  {
    1.21 -    Graph &G;
    1.22 -    Edge e;
    1.23 -  public:
    1.24 -    RefType(Graph &_G,Edge _e) : G(_G), e(_e) { }
    1.25 -    
    1.26 -    operator Value() const 
    1.27 -    {
    1.28 -      Value tmp;
    1.29 -      std::cout << G.id(G.source(e)) << "->"
    1.30 -		<< G.id(G.target(e)) << ": ";
    1.31 -      std::cin  >> tmp;
    1.32 -      return tmp;
    1.33 -    }
    1.34 -    Value operator = (Value v) const
    1.35 -    {
    1.36 -      std::cout << G.id(G.source(e)) << "->"
    1.37 -		<< G.id(G.target(e)) << ": " << v << '\n';
    1.38 -      return v;
    1.39 -    }
    1.40 -  };
    1.41 -  
    1.42 -private:
    1.43 -  Graph &G;
    1.44 -public:
    1.45 -  CinCoutMap(Graph &_G) : G(_G) { }
    1.46 -  RefType operator[] (Edge e) const { return RefType(G,e);}  
    1.47 -};
    1.48 -
    1.49 -template<class K,class T>
    1.50 -class NullMap
    1.51 -{
    1.52 -public:
    1.53 -  typedef K Key;
    1.54 -  typedef T Value;
    1.55 -  
    1.56 -  class RefType 
    1.57 -  {
    1.58 -    Value val;
    1.59 -  public:
    1.60 -    RefType(Value v) : val(v) { }   
    1.61 -    operator Value() const { return val; }
    1.62 -    Value operator = (Value v) const { return val; }
    1.63 -  };
    1.64 -  
    1.65 -private:
    1.66 -  Value val;
    1.67 -public:
    1.68 -  NullMap(Value v) : val(v) { }
    1.69 -  RefType operator[] (Key e) const { return RefType(v);}  
    1.70 -};
    1.71 -
    1.72 -int main()
    1.73 -{
    1.74 -  typedef SmartGraph Graph;
    1.75 -  typedef Graph::NodeIt NodeIt;
    1.76 -  typedef Graph::OutEdgeIt OutEdgeIt;
    1.77 -  typedef Graph::EdgeIt EdgeIt;
    1.78 -  
    1.79 -  Graph G;
    1.80 -
    1.81 -  CinCoutMap<Graph,int> map(G);
    1.82 -
    1.83 -  Graph::EdgeMap<int> emap(G);
    1.84 -  
    1.85 -  for(int i=0;i<3;i++) G.addNode();
    1.86 -
    1.87 -  for(NodeIt n(G);G.valid(n);G.next(n))
    1.88 -    for(NodeIt m(G);G.valid(m);G.next(m)) if(n!=m)
    1.89 -      G.addEdge(n,m);
    1.90 -
    1.91 -  //for(OutEdgeIt e(G,NodeIt(G));G.valid(e);G.next(e))
    1.92 -    
    1.93 -  for(EdgeIt e(G);G.valid(e);G.next(e)) emap[e] = map[e];
    1.94 -  
    1.95 -  std::cout << '\n';
    1.96 -  
    1.97 -  for(EdgeIt e(G);G.valid(e);G.next(e))  map[e] = emap[e];
    1.98 -
    1.99 -}
   1.100 -