[Lemon-commits] [lemon_svn] deba: r2236 - in hugo/trunk: doc lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:51:09 CET 2006
Author: deba
Date: Wed Oct 5 18:45:37 2005
New Revision: 2236
Modified:
hugo/trunk/doc/named-param.dox
hugo/trunk/lemon/bfs.h
hugo/trunk/lemon/dfs.h
hugo/trunk/lemon/dijkstra.h
hugo/trunk/lemon/topology.h
Log:
Template Named Parameter bugfix
Modified: hugo/trunk/doc/named-param.dox
==============================================================================
--- hugo/trunk/doc/named-param.dox (original)
+++ hugo/trunk/doc/named-param.dox Wed Oct 5 18:45:37 2005
@@ -82,14 +82,14 @@
be used like in the following cases.
\code
-Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >
+Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >::Create
\endcode
It can also be used in conjunction with other named template
parameters in arbitrary order.
\code
-Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >
+Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >::Create
\endcode
The result will be an instantiated Dijkstra class, in which the
Modified: hugo/trunk/lemon/bfs.h
==============================================================================
--- hugo/trunk/lemon/bfs.h (original)
+++ hugo/trunk/lemon/bfs.h Wed Oct 5 18:45:37 2005
@@ -57,24 +57,6 @@
{
return new PredMap(G);
}
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// ///
-// ///The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// ///It must meet the \ref concept::WriteMap "WriteMap" concept.
-// ///
-// typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
-// ///Instantiates a PredNodeMap.
-
-// ///This function instantiates a \ref PredNodeMap.
-// ///\param G is the graph, to which
-// ///we would like to define the \ref PredNodeMap
-// static PredNodeMap *createPredNodeMap(const GR &G)
-// {
-// return new PredNodeMap();
-// }
-
///The type of the map that indicates which nodes are processed.
///The type of the map that indicates which nodes are processed.
@@ -179,9 +161,6 @@
///\brief The type of the map that stores the last
///edges of the shortest paths.
typedef typename TR::PredMap PredMap;
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// typedef typename TR::PredNodeMap PredNodeMap;
///The type of the map indicating which nodes are reached.
typedef typename TR::ReachedMap ReachedMap;
///The type of the map indicating which nodes are processed.
@@ -195,10 +174,6 @@
PredMap *_pred;
///Indicates if \ref _pred is locally allocated (\c true) or not.
bool local_pred;
-// ///Pointer to the map of predecessors nodes.
-// PredNodeMap *_predNode;
-// ///Indicates if \ref _predNode is locally allocated (\c true) or not.
-// bool local_predNode;
///Pointer to the map of distances.
DistMap *_dist;
///Indicates if \ref _dist is locally allocated (\c true) or not.
@@ -215,8 +190,6 @@
std::vector<typename Graph::Node> _queue;
int _queue_head,_queue_tail,_queue_next_dist;
int _curr_dist;
-// ///The source node of the last execution.
-// Node source;
///Creates the maps if necessary.
@@ -228,10 +201,6 @@
local_pred = true;
_pred = Traits::createPredMap(*G);
}
-// if(!_predNode) {
-// local_predNode = true;
-// _predNode = Traits::createPredNodeMap(*G);
-// }
if(!_dist) {
local_dist = true;
_dist = Traits::createDistMap(*G);
@@ -265,24 +234,9 @@
///\ref named-templ-param "Named parameter" for setting PredMap type
///
template <class T>
- class DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > { };
-
-// template <class T>
-// struct DefPredNodeMapTraits : public Traits {
-// typedef T PredNodeMap;
-// static PredNodeMap *createPredNodeMap(const Graph &G)
-// {
-// throw UninitializedParameter();
-// }
-// };
-// ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
-
-// ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
-// ///
-// template <class T>
-// class DefPredNodeMap : public Bfs< Graph,
-// LengthMap,
-// DefPredNodeMapTraits<T> > { };
+ struct DefPredMap : public Bfs< Graph, DefPredMapTraits<T> > {
+ typedef Bfs< Graph, DefPredMapTraits<T> > Create;
+ };
template <class T>
struct DefDistMapTraits : public Traits {
@@ -297,8 +251,9 @@
///\ref named-templ-param "Named parameter" for setting DistMap type
///
template <class T>
- class DefDistMap : public Bfs< Graph,
- DefDistMapTraits<T> > { };
+ struct DefDistMap : public Bfs< Graph, DefDistMapTraits<T> > {
+ typedef Bfs< Graph, DefDistMapTraits<T> > Create;
+ };
template <class T>
struct DefReachedMapTraits : public Traits {
@@ -313,16 +268,10 @@
///\ref named-templ-param "Named parameter" for setting ReachedMap type
///
template <class T>
- class DefReachedMap : public Bfs< Graph,
- DefReachedMapTraits<T> > { };
-
- struct DefGraphReachedMapTraits : public Traits {
- typedef typename Graph::template NodeMap<bool> ReachedMap;
- static ReachedMap *createReachedMap(const Graph &G)
- {
- return new ReachedMap(G);
- }
+ struct DefReachedMap : public Bfs< Graph, DefReachedMapTraits<T> > {
+ typedef Bfs< Graph, DefReachedMapTraits<T> > Create;
};
+
template <class T>
struct DefProcessedMapTraits : public Traits {
typedef T ProcessedMap;
@@ -336,8 +285,9 @@
///\ref named-templ-param "Named parameter" for setting ProcessedMap type
///
template <class T>
- class DefProcessedMap : public Bfs< Graph,
- DefProcessedMapTraits<T> > { };
+ struct DefProcessedMap : public Bfs< Graph, DefProcessedMapTraits<T> > {
+ typedef Bfs< Graph, DefProcessedMapTraits<T> > Create;
+ };
struct DefGraphProcessedMapTraits : public Traits {
typedef typename Graph::template NodeMap<bool> ProcessedMap;
@@ -353,9 +303,10 @@
///for setting the ProcessedMap type to be Graph::NodeMap<bool>.
///If you don't set it explicitly, it will be automatically allocated.
template <class T>
- class DefProcessedMapToBeDefaultMap :
- public Bfs< Graph,
- DefGraphProcessedMapTraits> { };
+ struct DefProcessedMapToBeDefaultMap :
+ public Bfs< Graph, DefGraphProcessedMapTraits> {
+ typedef Bfs< Graph, DefGraphProcessedMapTraits> Create;
+ };
///@}
@@ -368,7 +319,6 @@
Bfs(const Graph& _G) :
G(&_G),
_pred(NULL), local_pred(false),
-// _predNode(NULL), local_predNode(false),
_dist(NULL), local_dist(false),
_reached(NULL), local_reached(false),
_processed(NULL), local_processed(false)
@@ -378,7 +328,6 @@
~Bfs()
{
if(local_pred) delete _pred;
-// if(local_predNode) delete _predNode;
if(local_dist) delete _dist;
if(local_reached) delete _reached;
if(local_processed) delete _processed;
@@ -435,23 +384,6 @@
return *this;
}
-// ///Sets the map storing the predecessor nodes.
-
-// ///Sets the map storing the predecessor nodes.
-// ///If you don't use this function before calling \ref run(),
-// ///it will allocate one. The destructor deallocates this
-// ///automatically allocated map, of course.
-// ///\return <tt> (*this) </tt>
-// Bfs &predNodeMap(PredNodeMap &m)
-// {
-// if(local_predNode) {
-// delete _predNode;
-// local_predNode=false;
-// }
-// _predNode = &m;
-// return *this;
-// }
-
///Sets the map storing the distances calculated by the algorithm.
///Sets the map storing the distances calculated by the algorithm.
@@ -494,7 +426,6 @@
_curr_dist=1;
for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
_pred->set(u,INVALID);
-// _predNode->set(u,INVALID);
_reached->set(u,false);
_processed->set(u,false);
}
@@ -537,7 +468,6 @@
_queue[_queue_head++]=m;
_reached->set(m,true);
_pred->set(m,e);
-// _pred_node->set(m,n);
_dist->set(m,_curr_dist);
}
return n;
@@ -745,13 +675,6 @@
///must be called before using this function.
const PredMap &predMap() const { return *_pred;}
-// ///Returns a reference to the map of nodes of shortest paths.
-
-// ///Returns a reference to the NodeMap of the last but one nodes of the
-// ///shortest path tree.
-// ///\pre \ref run() must be called before using this function.
-// const PredNodeMap &predNodeMap() const { return *_predNode;}
-
///Checks if a node is reachable from the root.
///Returns \c true if \c v is reachable from the root.
@@ -794,23 +717,6 @@
{
return new PredMap();
}
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// ///
-// ///The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// ///It must meet the \ref concept::WriteMap "WriteMap" concept.
-// ///
-// typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
-// ///Instantiates a PredNodeMap.
-
-// ///This function instantiates a \ref PredNodeMap.
-// ///\param G is the graph, to which
-// ///we would like to define the \ref PredNodeMap
-// static PredNodeMap *createPredNodeMap(const GR &G)
-// {
-// return new PredNodeMap();
-// }
///The type of the map that indicates which nodes are processed.
@@ -891,8 +797,6 @@
void *_processed;
///Pointer to the map of predecessors edges.
void *_pred;
-// ///Pointer to the map of predecessors nodes.
-// void *_predNode;
///Pointer to the map of distances.
void *_dist;
///Pointer to the source node.
@@ -904,7 +808,6 @@
/// This constructor does not require parameters, therefore it initiates
/// all of the attributes to default values (0, INVALID).
BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-// _predNode(0),
_dist(0), _source(INVALID) {}
/// Constructor.
@@ -916,7 +819,6 @@
/// \param s is the initial value of \ref _source
BfsWizardBase(const GR &g, Node s=INVALID) :
_g((void *)&g), _reached(0), _processed(0), _pred(0),
-// _predNode(0),
_dist(0), _source(s) {}
};
@@ -965,9 +867,6 @@
///\brief The type of the map that stores the last
///edges of the shortest paths.
typedef typename TR::PredMap PredMap;
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the shortest paths.
-// typedef typename TR::PredNodeMap PredNodeMap;
///The type of the map that stores the dists of the nodes.
typedef typename TR::DistMap DistMap;
@@ -999,7 +898,6 @@
alg.reachedMap(*(ReachedMap*)Base::_reached);
if(Base::_processed) alg.processedMap(*(ProcessedMap*)Base::_processed);
if(Base::_pred) alg.predMap(*(PredMap*)Base::_pred);
-// if(Base::_predNode) alg.predNodeMap(*(PredNodeMap*)Base::_predNode);
if(Base::_dist) alg.distMap(*(DistMap*)Base::_dist);
alg.run(Base::_source);
}
@@ -1076,26 +974,6 @@
return BfsWizard<DefProcessedMapBase<T> >(*this);
}
-
-// template<class T>
-// struct DefPredNodeMapBase : public Base {
-// typedef T PredNodeMap;
-// static PredNodeMap *createPredNodeMap(const Graph &G) { return 0; };
-// DefPredNodeMapBase(const TR &b) : TR(b) {}
-// };
-
-// ///\brief \ref named-templ-param "Named parameter"
-// ///function for setting PredNodeMap type
-// ///
-// /// \ref named-templ-param "Named parameter"
-// ///function for setting PredNodeMap type
-// ///
-// template<class T>
-// BfsWizard<DefPredNodeMapBase<T> > predNodeMap(const T &t)
-// {
-// Base::_predNode=(void *)&t;
-// return BfsWizard<DefPredNodeMapBase<T> >(*this);
-// }
template<class T>
struct DefDistMapBase : public Base {
Modified: hugo/trunk/lemon/dfs.h
==============================================================================
--- hugo/trunk/lemon/dfs.h (original)
+++ hugo/trunk/lemon/dfs.h Wed Oct 5 18:45:37 2005
@@ -57,23 +57,6 @@
{
return new PredMap(G);
}
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the %DFS paths.
-// ///
-// ///The type of the map that stores the last but one
-// ///nodes of the %DFS paths.
-// ///It must meet the \ref concept::WriteMap "WriteMap" concept.
-// ///
-// typedef NullMap<typename Graph::Node,typename Graph::Node> PredNodeMap;
-// ///Instantiates a PredNodeMap.
-
-// ///This function instantiates a \ref PredNodeMap.
-// ///\param G is the graph, to which
-// ///we would like to define the \ref PredNodeMap
-// static PredNodeMap *createPredNodeMap(const GR &G)
-// {
-// return new PredNodeMap();
-// }
///The type of the map that indicates which nodes are processed.
@@ -179,9 +162,6 @@
///\brief The type of the map that stores the last
///edges of the %DFS paths.
typedef typename TR::PredMap PredMap;
-// ///\brief The type of the map that stores the last but one
-// ///nodes of the %DFS paths.
-// typedef typename TR::PredNodeMap PredNodeMap;
///The type of the map indicating which nodes are reached.
typedef typename TR::ReachedMap ReachedMap;
///The type of the map indicating which nodes are processed.
@@ -195,10 +175,6 @@
PredMap *_pred;
///Indicates if \ref _pred is locally allocated (\c true) or not.
bool local_pred;
-// ///Pointer to the map of predecessors nodes.
-// PredNodeMap *_predNode;
-// ///Indicates if \ref _predNode is locally allocated (\c true) or not.
-// bool local_predNode;
///Pointer to the map of distances.
DistMap *_dist;
///Indicates if \ref _dist is locally allocated (\c true) or not.
@@ -214,8 +190,6 @@
std::vector<typename Graph::OutEdgeIt> _stack;
int _stack_head;
-// ///The source node of the last execution.
-// Node source;
///Creates the maps if necessary.
@@ -227,10 +201,6 @@
local_pred = true;
_pred = Traits::createPredMap(*G);
}
-// if(!_predNode) {
-// local_predNode = true;
-// _predNode = Traits::createPredNodeMap(*G);
-// }
if(!_dist) {
local_dist = true;
_dist = Traits::createDistMap(*G);
@@ -246,7 +216,9 @@
}
public :
-
+
+ typedef Dfs Create;
+
///\name Named template parameters
///@{
@@ -264,25 +236,10 @@
///\ref named-templ-param "Named parameter" for setting PredMap type
///
template <class T>
- class DefPredMap : public Dfs< Graph,
- DefPredMapTraits<T> > { };
+ struct DefPredMap : public Dfs<Graph, DefPredMapTraits<T> > {
+ typedef Dfs<Graph, DefPredMapTraits<T> > Create;
+ };
-// template <class T>
-// struct DefPredNodeMapTraits : public Traits {
-// typedef T PredNodeMap;
-// static PredNodeMap *createPredNodeMap(const Graph &G)
-// {
-// throw UninitializedParameter();
-// }
-// };
-// ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
-
-// ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
-// ///
-// template <class T>
-// class DefPredNodeMap : public Dfs< Graph,
-// LengthMap,
-// DefPredNodeMapTraits<T> > { };
template <class T>
struct DefDistMapTraits : public Traits {
@@ -297,8 +254,9 @@
///\ref named-templ-param "Named parameter" for setting DistMap type
///
template <class T>
- class DefDistMap : public Dfs< Graph,
- DefDistMapTraits<T> > { };
+ struct DefDistMap {
+ typedef Dfs<Graph, DefDistMapTraits<T> > Create;
+ };
template <class T>
struct DefReachedMapTraits : public Traits {
@@ -313,16 +271,10 @@
///\ref named-templ-param "Named parameter" for setting ReachedMap type
///
template <class T>
- class DefReachedMap : public Dfs< Graph,
- DefReachedMapTraits<T> > { };
-
- struct DefGraphReachedMapTraits : public Traits {
- typedef typename Graph::template NodeMap<bool> ReachedMap;
- static ReachedMap *createReachedMap(const Graph &G)
- {
- return new ReachedMap(G);
- }
+ struct DefReachedMap {
+ typedef Dfs< Graph, DefReachedMapTraits<T> > Create;
};
+
template <class T>
struct DefProcessedMapTraits : public Traits {
typedef T ProcessedMap;
@@ -337,7 +289,7 @@
///
template <class T>
struct DefProcessedMap : public Dfs< Graph, DefProcessedMapTraits<T> > {
- typedef Dfs< Graph, DefProcessedMapTraits<T> > Dfs;
+ typedef Dfs< Graph, DefProcessedMapTraits<T> > Create;
};
struct DefGraphProcessedMapTraits : public Traits {
@@ -355,8 +307,9 @@
///If you don't set it explicitely, it will be automatically allocated.
template <class T>
class DefProcessedMapToBeDefaultMap :
- public Dfs< Graph,
- DefGraphProcessedMapTraits> { };
+ public Dfs< Graph, DefGraphProcessedMapTraits> {
+ typedef Dfs< Graph, DefGraphProcessedMapTraits> Create;
+ };
///@}
Modified: hugo/trunk/lemon/dijkstra.h
==============================================================================
--- hugo/trunk/lemon/dijkstra.h (original)
+++ hugo/trunk/lemon/dijkstra.h Wed Oct 5 18:45:37 2005
@@ -56,8 +56,7 @@
///
///\sa BinHeap
///\sa Dijkstra
- typedef BinHeap<typename Graph::Node,
- typename LM::Value,
+ typedef BinHeap<typename Graph::Node, typename LM::Value,
typename GR::template NodeMap<int>,
std::less<Value> > Heap;
@@ -255,9 +254,10 @@
///\ref named-templ-param "Named parameter" for setting PredMap type
///
template <class T>
- class DefPredMap : public Dijkstra< Graph,
- LengthMap,
- DefPredMapTraits<T> > { };
+ struct DefPredMap
+ : public Dijkstra< Graph, LengthMap, DefPredMapTraits<T> > {
+ typedef Dijkstra< Graph, LengthMap, DefPredMapTraits<T> > Create;
+ };
template <class T>
struct DefDistMapTraits : public Traits {
@@ -272,9 +272,10 @@
///\ref named-templ-param "Named parameter" for setting DistMap type
///
template <class T>
- class DefDistMap : public Dijkstra< Graph,
- LengthMap,
- DefDistMapTraits<T> > { };
+ struct DefDistMap
+ : public Dijkstra< Graph, LengthMap, DefDistMapTraits<T> > {
+ typedef Dijkstra< Graph, LengthMap, DefDistMapTraits<T> > Create;
+ };
template <class T>
struct DefProcessedMapTraits : public Traits {
@@ -289,9 +290,10 @@
///\ref named-templ-param "Named parameter" for setting ProcessedMap type
///
template <class T>
- class DefProcessedMap : public Dijkstra< Graph,
- LengthMap,
- DefProcessedMapTraits<T> > { };
+ struct DefProcessedMap
+ : public Dijkstra< Graph, LengthMap, DefProcessedMapTraits<T> > {
+ typedef Dijkstra< Graph, LengthMap, DefProcessedMapTraits<T> > Create;
+ };
struct DefGraphProcessedMapTraits : public Traits {
typedef typename Graph::template NodeMap<bool> ProcessedMap;
@@ -307,10 +309,10 @@
///for setting the ProcessedMap type to be Graph::NodeMap<bool>.
///If you don't set it explicitely, it will be automatically allocated.
template <class T>
- class DefProcessedMapToBeDefaultMap :
- public Dijkstra< Graph,
- LengthMap,
- DefGraphProcessedMapTraits> { };
+ struct DefProcessedMapToBeDefaultMap
+ : public Dijkstra< Graph, LengthMap, DefGraphProcessedMapTraits> {
+ typedef Dijkstra< Graph, LengthMap, DefGraphProcessedMapTraits> Create;
+ };
///@}
Modified: hugo/trunk/lemon/topology.h
==============================================================================
--- hugo/trunk/lemon/topology.h (original)
+++ hugo/trunk/lemon/topology.h Wed Oct 5 18:45:37 2005
@@ -73,7 +73,7 @@
typedef BackCounterMap<NodeMap> ProcessedMap;
typename Dfs<Graph>::template DefProcessedMap<ProcessedMap>::
- Dfs dfs(graph);
+ Create dfs(graph);
ProcessedMap processed(nodeMap, countNodes(graph));
@@ -111,7 +111,7 @@
typedef typename Graph::template NodeMap<bool> ProcessedMap;
typename Dfs<Graph>::template DefProcessedMap<ProcessedMap>::
- Dfs dfs(graph);
+ Create dfs(graph);
ProcessedMap processed(graph);
dfs.processedMap(processed);
More information about the Lemon-commits
mailing list