COIN-OR::LEMON - Graph Library

Changeset 1709:a323456bf7c8 in lemon-0.x


Ignore:
Timestamp:
10/05/05 18:45:37 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2236
Message:

Template Named Parameter bugfix

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • doc/named-param.dox

    r1624 r1709  
    8383
    8484\code
    85 Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >
     85Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >::Create
    8686\endcode
    8787
     
    9090
    9191\code
    92 Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >
     92Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >::Create
    9393\endcode
    9494
  • lemon/bfs.h

    r1694 r1709  
    5858      return new PredMap(G);
    5959    }
    60 //     ///\brief The type of the map that stores the last but one
    61 //     ///nodes of the shortest paths.
    62 //     ///
    63 //     ///The type of the map that stores the last but one
    64 //     ///nodes of the shortest paths.
    65 //     ///It must meet the \ref concept::WriteMap "WriteMap" concept.
    66 //     ///
    67 //     typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
    68 //     ///Instantiates a PredNodeMap.
    69    
    70 //     ///This function instantiates a \ref PredNodeMap.
    71 //     ///\param G is the graph, to which
    72 //     ///we would like to define the \ref PredNodeMap
    73 //     static PredNodeMap *createPredNodeMap(const GR &G)
    74 //     {
    75 //       return new PredNodeMap();
    76 //     }
    77 
    7860    ///The type of the map that indicates which nodes are processed.
    7961 
     
    180162    ///edges of the shortest paths.
    181163    typedef typename TR::PredMap PredMap;
    182 //     ///\brief The type of the map that stores the last but one
    183 //     ///nodes of the shortest paths.
    184 //     typedef typename TR::PredNodeMap PredNodeMap;
    185164    ///The type of the map indicating which nodes are reached.
    186165    typedef typename TR::ReachedMap ReachedMap;
     
    196175    ///Indicates if \ref _pred is locally allocated (\c true) or not.
    197176    bool local_pred;
    198 //     ///Pointer to the map of predecessors nodes.
    199 //     PredNodeMap *_predNode;
    200 //     ///Indicates if \ref _predNode is locally allocated (\c true) or not.
    201 //     bool local_predNode;
    202177    ///Pointer to the map of distances.
    203178    DistMap *_dist;
     
    216191    int _queue_head,_queue_tail,_queue_next_dist;
    217192    int _curr_dist;
    218 //     ///The source node of the last execution.
    219 //     Node source;
    220193
    221194    ///Creates the maps if necessary.
     
    229202        _pred = Traits::createPredMap(*G);
    230203      }
    231 //       if(!_predNode) {
    232 //      local_predNode = true;
    233 //      _predNode = Traits::createPredNodeMap(*G);
    234 //       }
    235204      if(!_dist) {
    236205        local_dist = true;
     
    266235    ///
    267236    template <class T>
    268     class DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > { };
    269    
    270 //     template <class T>
    271 //     struct DefPredNodeMapTraits : public Traits {
    272 //       typedef T PredNodeMap;
    273 //       static PredNodeMap *createPredNodeMap(const Graph &G)
    274 //       {
    275 //      throw UninitializedParameter();
    276 //       }
    277 //     };
    278 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    279 
    280 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    281 //     ///
    282 //     template <class T>
    283 //     class DefPredNodeMap : public Bfs< Graph,
    284 //                                          LengthMap,
    285 //                                          DefPredNodeMapTraits<T> > { };
     237    struct DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > {
     238      typedef Bfs< Graph, DefPredMapTraits<T> > Create;
     239    };
    286240   
    287241    template <class T>
     
    298252    ///
    299253    template <class T>
    300     class DefDistMap : public Bfs< Graph,
    301                                    DefDistMapTraits<T> > { };
     254    struct DefDistMap : public Bfs< Graph, DefDistMapTraits<T> > {
     255      typedef Bfs< Graph, DefDistMapTraits<T> > Create;
     256    };
    302257   
    303258    template <class T>
     
    314269    ///
    315270    template <class T>
    316     class DefReachedMap : public Bfs< Graph,
    317                                       DefReachedMapTraits<T> > { };
    318    
    319     struct DefGraphReachedMapTraits : public Traits {
    320       typedef typename Graph::template NodeMap<bool> ReachedMap;
    321       static ReachedMap *createReachedMap(const Graph &G)
    322       {
    323         return new ReachedMap(G);
    324       }
    325     };
     271    struct DefReachedMap : public Bfs< Graph, DefReachedMapTraits<T> > {
     272      typedef Bfs< Graph, DefReachedMapTraits<T> > Create;
     273    };
     274   
    326275    template <class T>
    327276    struct DefProcessedMapTraits : public Traits {
     
    337286    ///
    338287    template <class T>
    339     class DefProcessedMap : public Bfs< Graph,
    340                                         DefProcessedMapTraits<T> > { };
     288    struct DefProcessedMap : public Bfs< Graph, DefProcessedMapTraits<T> > {
     289      typedef Bfs< Graph, DefProcessedMapTraits<T> > Create;
     290    };
    341291   
    342292    struct DefGraphProcessedMapTraits : public Traits {
     
    354304    ///If you don't set it explicitly, it will be automatically allocated.
    355305    template <class T>
    356     class DefProcessedMapToBeDefaultMap :
    357       public Bfs< Graph,
    358                   DefGraphProcessedMapTraits> { };
     306    struct DefProcessedMapToBeDefaultMap :
     307      public Bfs< Graph, DefGraphProcessedMapTraits> {
     308      typedef Bfs< Graph, DefGraphProcessedMapTraits> Create;
     309    };
    359310   
    360311    ///@}
     
    369320      G(&_G),
    370321      _pred(NULL), local_pred(false),
    371 //       _predNode(NULL), local_predNode(false),
    372322      _dist(NULL), local_dist(false),
    373323      _reached(NULL), local_reached(false),
     
    379329    {
    380330      if(local_pred) delete _pred;
    381 //       if(local_predNode) delete _predNode;
    382331      if(local_dist) delete _dist;
    383332      if(local_reached) delete _reached;
     
    435384      return *this;
    436385    }
    437 
    438 //     ///Sets the map storing the predecessor nodes.
    439 
    440 //     ///Sets the map storing the predecessor nodes.
    441 //     ///If you don't use this function before calling \ref run(),
    442 //     ///it will allocate one. The destructor deallocates this
    443 //     ///automatically allocated map, of course.
    444 //     ///\return <tt> (*this) </tt>
    445 //     Bfs &predNodeMap(PredNodeMap &m)
    446 //     {
    447 //       if(local_predNode) {
    448 //      delete _predNode;
    449 //      local_predNode=false;
    450 //       }
    451 //       _predNode = &m;
    452 //       return *this;
    453 //     }
    454386
    455387    ///Sets the map storing the distances calculated by the algorithm.
     
    495427      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
    496428        _pred->set(u,INVALID);
    497 //      _predNode->set(u,INVALID);
    498429        _reached->set(u,false);
    499430        _processed->set(u,false);
     
    538469          _reached->set(m,true);
    539470          _pred->set(m,e);
    540 //        _pred_node->set(m,n);
    541471          _dist->set(m,_curr_dist);
    542472        }
     
    746676    const PredMap &predMap() const { return *_pred;}
    747677 
    748 //     ///Returns a reference to the map of nodes of shortest paths.
    749 
    750 //     ///Returns a reference to the NodeMap of the last but one nodes of the
    751 //     ///shortest path tree.
    752 //     ///\pre \ref run() must be called before using this function.
    753 //     const PredNodeMap &predNodeMap() const { return *_predNode;}
    754 
    755678    ///Checks if a node is reachable from the root.
    756679
     
    795718      return new PredMap();
    796719    }
    797 //     ///\brief The type of the map that stores the last but one
    798 //     ///nodes of the shortest paths.
    799 //     ///
    800 //     ///The type of the map that stores the last but one
    801 //     ///nodes of the shortest paths.
    802 //     ///It must meet the \ref concept::WriteMap "WriteMap" concept.
    803 //     ///
    804 //     typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
    805 //     ///Instantiates a PredNodeMap.
    806    
    807 //     ///This function instantiates a \ref PredNodeMap.
    808 //     ///\param G is the graph, to which
    809 //     ///we would like to define the \ref PredNodeMap
    810 //     static PredNodeMap *createPredNodeMap(const GR &G)
    811 //     {
    812 //       return new PredNodeMap();
    813 //     }
    814720
    815721    ///The type of the map that indicates which nodes are processed.
     
    892798    ///Pointer to the map of predecessors edges.
    893799    void *_pred;
    894 //     ///Pointer to the map of predecessors nodes.
    895 //     void *_predNode;
    896800    ///Pointer to the map of distances.
    897801    void *_dist;
     
    905809    /// all of the attributes to default values (0, INVALID).
    906810    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
    907 //                         _predNode(0),
    908811                           _dist(0), _source(INVALID) {}
    909812
     
    917820    BfsWizardBase(const GR &g, Node s=INVALID) :
    918821      _g((void *)&g), _reached(0), _processed(0), _pred(0),
    919 //       _predNode(0),
    920822      _dist(0), _source(s) {}
    921823
     
    966868    ///edges of the shortest paths.
    967869    typedef typename TR::PredMap PredMap;
    968 //     ///\brief The type of the map that stores the last but one
    969 //     ///nodes of the shortest paths.
    970 //     typedef typename TR::PredNodeMap PredNodeMap;
    971870    ///The type of the map that stores the dists of the nodes.
    972871    typedef typename TR::DistMap DistMap;
     
    1000899      if(Base::_processed) alg.processedMap(*(ProcessedMap*)Base::_processed);
    1001900      if(Base::_pred) alg.predMap(*(PredMap*)Base::_pred);
    1002 //       if(Base::_predNode) alg.predNodeMap(*(PredNodeMap*)Base::_predNode);
    1003901      if(Base::_dist) alg.distMap(*(DistMap*)Base::_dist);
    1004902      alg.run(Base::_source);
     
    1077975    }
    1078976   
    1079 
    1080 //     template<class T>
    1081 //     struct DefPredNodeMapBase : public Base {
    1082 //       typedef T PredNodeMap;
    1083 //       static PredNodeMap *createPredNodeMap(const Graph &G) { return 0; };
    1084 //       DefPredNodeMapBase(const TR &b) : TR(b) {}
    1085 //     };
    1086    
    1087 //     ///\brief \ref named-templ-param "Named parameter"
    1088 //     ///function for setting PredNodeMap type
    1089 //     ///
    1090 //     /// \ref named-templ-param "Named parameter"
    1091 //     ///function for setting PredNodeMap type
    1092 //     ///
    1093 //     template<class T>
    1094 //     BfsWizard<DefPredNodeMapBase<T> > predNodeMap(const T &t)
    1095 //     {
    1096 //       Base::_predNode=(void *)&t;
    1097 //       return BfsWizard<DefPredNodeMapBase<T> >(*this);
    1098 //     }
    1099977   
    1100978    template<class T>
  • lemon/dfs.h

    r1694 r1709  
    5858      return new PredMap(G);
    5959    }
    60 //     ///\brief The type of the map that stores the last but one
    61 //     ///nodes of the %DFS paths.
    62 //     ///
    63 //     ///The type of the map that stores the last but one
    64 //     ///nodes of the %DFS paths.
    65 //     ///It must meet the \ref concept::WriteMap "WriteMap" concept.
    66 //     ///
    67 //     typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
    68 //     ///Instantiates a PredNodeMap.
    69    
    70 //     ///This function instantiates a \ref PredNodeMap.
    71 //     ///\param G is the graph, to which
    72 //     ///we would like to define the \ref PredNodeMap
    73 //     static PredNodeMap *createPredNodeMap(const GR &G)
    74 //     {
    75 //       return new PredNodeMap();
    76 //     }
    7760
    7861    ///The type of the map that indicates which nodes are processed.
     
    180163    ///edges of the %DFS paths.
    181164    typedef typename TR::PredMap PredMap;
    182 //     ///\brief The type of the map that stores the last but one
    183 //     ///nodes of the %DFS paths.
    184 //     typedef typename TR::PredNodeMap PredNodeMap;
    185165    ///The type of the map indicating which nodes are reached.
    186166    typedef typename TR::ReachedMap ReachedMap;
     
    196176    ///Indicates if \ref _pred is locally allocated (\c true) or not.
    197177    bool local_pred;
    198 //     ///Pointer to the map of predecessors nodes.
    199 //     PredNodeMap *_predNode;
    200 //     ///Indicates if \ref _predNode is locally allocated (\c true) or not.
    201 //     bool local_predNode;
    202178    ///Pointer to the map of distances.
    203179    DistMap *_dist;
     
    215191    std::vector<typename Graph::OutEdgeIt> _stack;
    216192    int _stack_head;
    217 //     ///The source node of the last execution.
    218 //     Node source;
    219193
    220194    ///Creates the maps if necessary.
     
    228202        _pred = Traits::createPredMap(*G);
    229203      }
    230 //       if(!_predNode) {
    231 //      local_predNode = true;
    232 //      _predNode = Traits::createPredNodeMap(*G);
    233 //       }
    234204      if(!_dist) {
    235205        local_dist = true;
     
    247217   
    248218  public :
    249  
     219
     220    typedef Dfs Create;
     221
    250222    ///\name Named template parameters
    251223
     
    265237    ///
    266238    template <class T>
    267     class DefPredMap : public Dfs< Graph,
    268                                         DefPredMapTraits<T> > { };
    269    
    270 //     template <class T>
    271 //     struct DefPredNodeMapTraits : public Traits {
    272 //       typedef T PredNodeMap;
    273 //       static PredNodeMap *createPredNodeMap(const Graph &G)
    274 //       {
    275 //      throw UninitializedParameter();
    276 //       }
    277 //     };
    278 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    279 
    280 //     ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
    281 //     ///
    282 //     template <class T>
    283 //     class DefPredNodeMap : public Dfs< Graph,
    284 //                                          LengthMap,
    285 //                                          DefPredNodeMapTraits<T> > { };
     239    struct DefPredMap : public Dfs<Graph, DefPredMapTraits<T> > {
     240      typedef Dfs<Graph, DefPredMapTraits<T> > Create;
     241    };
     242   
    286243   
    287244    template <class T>
     
    298255    ///
    299256    template <class T>
    300     class DefDistMap : public Dfs< Graph,
    301                                    DefDistMapTraits<T> > { };
     257    struct DefDistMap {
     258      typedef Dfs<Graph, DefDistMapTraits<T> > Create;
     259    };
    302260   
    303261    template <class T>
     
    314272    ///
    315273    template <class T>
    316     class DefReachedMap : public Dfs< Graph,
    317                                       DefReachedMapTraits<T> > { };
    318    
    319     struct DefGraphReachedMapTraits : public Traits {
    320       typedef typename Graph::template NodeMap<bool> ReachedMap;
    321       static ReachedMap *createReachedMap(const Graph &G)
    322       {
    323         return new ReachedMap(G);
    324       }
    325     };
     274    struct DefReachedMap {
     275      typedef Dfs< Graph, DefReachedMapTraits<T> > Create;
     276    };
     277
    326278    template <class T>
    327279    struct DefProcessedMapTraits : public Traits {
     
    338290    template <class T>
    339291    struct DefProcessedMap : public Dfs< Graph, DefProcessedMapTraits<T> > {
    340       typedef Dfs< Graph, DefProcessedMapTraits<T> > Dfs;
     292      typedef Dfs< Graph, DefProcessedMapTraits<T> > Create;
    341293    };
    342294   
     
    356308    template <class T>
    357309    class DefProcessedMapToBeDefaultMap :
    358       public Dfs< Graph,
    359                   DefGraphProcessedMapTraits> { };
     310      public Dfs< Graph, DefGraphProcessedMapTraits> {
     311      typedef Dfs< Graph, DefGraphProcessedMapTraits> Create;
     312    };
    360313   
    361314    ///@}
  • lemon/dijkstra.h

    r1694 r1709  
    5757    ///\sa BinHeap
    5858    ///\sa Dijkstra
    59     typedef BinHeap<typename Graph::Node,
    60                     typename LM::Value,
     59    typedef BinHeap<typename Graph::Node, typename LM::Value,
    6160                    typename GR::template NodeMap<int>,
    6261                    std::less<Value> > Heap;
     
    256255    ///
    257256    template <class T>
    258     class DefPredMap : public Dijkstra< Graph,
    259                                         LengthMap,
    260                                         DefPredMapTraits<T> > { };
     257    struct DefPredMap
     258      : public Dijkstra< Graph, LengthMap, DefPredMapTraits<T> > {
     259      typedef Dijkstra< Graph,  LengthMap, DefPredMapTraits<T> > Create;
     260    };
    261261   
    262262    template <class T>
     
    273273    ///
    274274    template <class T>
    275     class DefDistMap : public Dijkstra< Graph,
    276                                         LengthMap,
    277                                         DefDistMapTraits<T> > { };
     275    struct DefDistMap
     276      : public Dijkstra< Graph, LengthMap, DefDistMapTraits<T> > {
     277      typedef Dijkstra< Graph, LengthMap, DefDistMapTraits<T> > Create;
     278    };
    278279   
    279280    template <class T>
     
    290291    ///
    291292    template <class T>
    292     class DefProcessedMap : public Dijkstra< Graph,
    293                                         LengthMap,
    294                                         DefProcessedMapTraits<T> > { };
     293    struct DefProcessedMap
     294      : public Dijkstra< Graph, LengthMap, DefProcessedMapTraits<T> > {
     295      typedef Dijkstra< Graph,  LengthMap, DefProcessedMapTraits<T> > Create;
     296    };
    295297   
    296298    struct DefGraphProcessedMapTraits : public Traits {
     
    308310    ///If you don't set it explicitely, it will be automatically allocated.
    309311    template <class T>
    310     class DefProcessedMapToBeDefaultMap :
    311       public Dijkstra< Graph,
    312                        LengthMap,
    313                        DefGraphProcessedMapTraits> { };
     312    struct DefProcessedMapToBeDefaultMap
     313      : public Dijkstra< Graph, LengthMap, DefGraphProcessedMapTraits> {
     314      typedef Dijkstra< Graph, LengthMap, DefGraphProcessedMapTraits> Create;
     315    };
    314316   
    315317    ///@}
  • lemon/topology.h

    r1698 r1709  
    7474
    7575    typename Dfs<Graph>::template DefProcessedMap<ProcessedMap>::
    76       Dfs dfs(graph);
     76      Create dfs(graph);
    7777
    7878    ProcessedMap processed(nodeMap, countNodes(graph));
     
    112112
    113113    typename Dfs<Graph>::template DefProcessedMap<ProcessedMap>::
    114       Dfs dfs(graph);
     114      Create dfs(graph);
    115115
    116116    ProcessedMap processed(graph);
Note: See TracChangeset for help on using the changeset viewer.