[Lemon-commits] [lemon_svn] alpar: r934 - in hugo/trunk/src/work: alpar klao
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:17 CET 2006
Author: alpar
Date: Wed Jun 16 11:44:30 2004
New Revision: 934
Removed:
hugo/trunk/src/work/alpar/path.h
Modified:
hugo/trunk/src/work/klao/path.h
Log:
src/work/alpar/path.h (docs) is merged into src/work/klao/path.h
(and removed)
Modified: hugo/trunk/src/work/klao/path.h
==============================================================================
--- hugo/trunk/src/work/klao/path.h (original)
+++ hugo/trunk/src/work/klao/path.h Wed Jun 16 11:44:30 2004
@@ -1,6 +1,20 @@
// -*- c++ -*- //
-///\ingroup datas
+/**
+ at defgroup paths Path Structures
+ at ingroup datas
+\brief Path structures implemented in Hugo.
+
+Hugolib provides flexible data structures
+to work with paths.
+
+All of them have the same interface, especially they can be built or extended
+using a standard Builder subclass. This make is easy to have e.g. the Dijkstra
+algorithm to store its result in any kind of path structure.
+
+*/
+
+///\ingroup paths
///\file
///\brief Classes for representing paths in graphs.
@@ -17,7 +31,7 @@
namespace hugo {
- /// \addtogroup datas
+ /// \addtogroup paths
/// @{
@@ -35,7 +49,9 @@
template<typename Graph, typename DM = DefaultDebugMode>
class DirPath {
public:
- typedef typename Graph::Edge GraphEdge;
+ /// Edge type of the underlying graph.
+ typedef typename Graph::Edge GraphEdge;
+ /// Node type of the underlying graph.
typedef typename Graph::Node GraphNode;
class NodeIt;
class EdgeIt;
@@ -152,27 +168,49 @@
}
- /*** Iterator classes ***/
+ /* Iterator classes */
+
+ /**
+ * \brief Iterator class to iterate on the edges of the paths
+ *
+ * \ingroup paths
+ * This class is used to iterate on the edges of the paths
+ *
+ * Of course it converts to Graph::Edge
+ *
+ * \todo Its interface differs from the standard edge iterator.
+ * Yes, it shouldn't.
+ */
class EdgeIt {
friend class DirPath;
int idx;
const DirPath *p;
public:
+ /// Default constructor
EdgeIt() {}
+ /// Invalid constructor
EdgeIt(Invalid) : idx(-1), p(0) {}
+ /// Constructor with starting point
EdgeIt(const DirPath &_p, int _idx = 0) :
idx(_idx), p(&_p) { validate(); }
+ ///Validity check
bool valid() const { return idx!=-1; }
+ ///Conversion to Graph::Edge
operator GraphEdge () const {
return valid() ? p->edges[idx] : INVALID;
}
+
+ /// Next edge
EdgeIt& operator++() { ++idx; validate(); return *this; }
+ /// Comparison operator
bool operator==(const EdgeIt& e) const { return idx==e.idx; }
+ /// Comparison operator
bool operator!=(const EdgeIt& e) const { return idx!=e.idx; }
+ /// Comparison operator
bool operator<(const EdgeIt& e) const { return idx<e.idx; }
private:
@@ -181,19 +219,35 @@
void validate() { if( size_t(idx) >= p->length() ) idx=-1; }
};
+ /**
+ * \brief Iterator class to iterate on the nodes of the paths
+ *
+ * \ingroup paths
+ * This class is used to iterate on the nodes of the paths
+ *
+ * Of course it converts to Graph::Node
+ *
+ * \todo Its interface differs from the standard node iterator.
+ * Yes, it shouldn't.
+ */
class NodeIt {
friend class DirPath;
int idx;
const DirPath *p;
public:
+ /// Default constructor
NodeIt() {}
+ /// Invalid constructor
NodeIt(Invalid) : idx(-1), p(0) {}
+ /// Constructor with starting point
NodeIt(const DirPath &_p, int _idx = 0) :
idx(_idx), p(&_p) { validate(); }
+ ///Validity check
bool valid() const { return idx!=-1; }
+ ///Conversion to Graph::Node
operator const GraphNode& () const {
if(idx >= p->length())
return p->to();
@@ -202,10 +256,14 @@
else
return INVALID;
}
+ /// Next node
NodeIt& operator++() { ++idx; validate(); return *this; }
+ /// Comparison operator
bool operator==(const NodeIt& e) const { return idx==e.idx; }
+ /// Comparison operator
bool operator!=(const NodeIt& e) const { return idx!=e.idx; }
+ /// Comparison operator
bool operator<(const NodeIt& e) const { return idx<e.idx; }
private:
@@ -217,7 +275,7 @@
/**
* \brief Class to build paths
*
- * \ingroup datas
+ * \ingroup paths
* This class is used to fill a path with edges.
*
* You can push new edges to the front and to the back of the path in
@@ -285,6 +343,11 @@
// FIXME: Hmm, pontosan hogy is kene ezt csinalni?
// Hogy kenyelmes egy ilyet hasznalni?
+
+ ///Reserve storage in advance for the builder
+
+ ///If you know an reasonable upper bound of the number of the edges
+ ///to add, using this function you can speed up the building.
void reserve(size_t r) {
front.reserve(r);
back.reserve(r);
@@ -349,8 +412,10 @@
template<typename Graph, typename DM = DefaultDebugMode>
class UndirPath {
public:
+ /// Edge type of the underlying graph.
typedef typename Graph::Edge GraphEdge;
- typedef typename Graph::Node GraphNode;
+ /// Node type of the underlying graph.
+ typedef typename Graph::Node GraphNode;
class NodeIt;
class EdgeIt;
@@ -466,27 +531,47 @@
}
- /*** Iterator classes ***/
+
+ /**
+ * \brief Iterator class to iterate on the edges of the paths
+ *
+ * \ingroup paths
+ * This class is used to iterate on the edges of the paths
+ *
+ * Of course it converts to Graph::Edge
+ *
+ * \todo Its interface differs from the standard edge iterator.
+ * Yes, it shouldn't.
+ */
class EdgeIt {
friend class UndirPath;
int idx;
const UndirPath *p;
public:
+ /// Default constructor
EdgeIt() {}
+ /// Invalid constructor
EdgeIt(Invalid) : idx(-1), p(0) {}
+ /// Constructor with starting point
EdgeIt(const UndirPath &_p, int _idx = 0) :
idx(_idx), p(&_p) { validate(); }
+ ///Validity check
bool valid() const { return idx!=-1; }
+ ///Conversion to Graph::Edge
operator GraphEdge () const {
return valid() ? p->edges[idx] : INVALID;
}
- EdgeIt& operator++() { ++idx; validate(); return *this; }
+ /// Next edge
+ EdgeIt& operator++() { ++idx; validate(); return *this; }
+ /// Comparison operator
bool operator==(const EdgeIt& e) const { return idx==e.idx; }
+ /// Comparison operator
bool operator!=(const EdgeIt& e) const { return idx!=e.idx; }
+ /// Comparison operator
bool operator<(const EdgeIt& e) const { return idx<e.idx; }
private:
@@ -495,19 +580,35 @@
void validate() { if( size_t(idx) >= p->length() ) idx=-1; }
};
+ /**
+ * \brief Iterator class to iterate on the nodes of the paths
+ *
+ * \ingroup paths
+ * This class is used to iterate on the nodes of the paths
+ *
+ * Of course it converts to Graph::Node
+ *
+ * \todo Its interface differs from the standard node iterator.
+ * Yes, it shouldn't.
+ */
class NodeIt {
friend class UndirPath;
int idx;
const UndirPath *p;
public:
+ /// Default constructor
NodeIt() {}
+ /// Invalid constructor
NodeIt(Invalid) : idx(-1), p(0) {}
+ /// Constructor with starting point
NodeIt(const UndirPath &_p, int _idx = 0) :
idx(_idx), p(&_p) { validate(); }
+ ///Validity check
bool valid() const { return idx!=-1; }
+ ///Conversion to Graph::Node
operator const GraphNode& () const {
if(idx >= p->length())
return p->to();
@@ -516,11 +617,15 @@
else
return INVALID;
}
+ /// Next node
NodeIt& operator++() { ++idx; validate(); return *this; }
+ /// Comparison operator
bool operator==(const NodeIt& e) const { return idx==e.idx; }
+ /// Comparison operator
bool operator!=(const NodeIt& e) const { return idx!=e.idx; }
- bool operator<(const NodeIt& e) const { return idx<e.idx; }
+ /// Comparison operator
+ bool operator<(const NodeIt& e) const { return idx<e.idx; }
private:
void validate() { if( size_t(idx) > p->length() ) idx=-1; }
@@ -531,7 +636,7 @@
/**
* \brief Class to build paths
*
- * \ingroup datas
+ * \ingroup paths
* This class is used to fill a path with edges.
*
* You can push new edges to the front and to the back of the path in
@@ -599,7 +704,12 @@
// FIXME: Hmm, pontosan hogy is kene ezt csinalni?
// Hogy kenyelmes egy ilyet hasznalni?
- void reserve(size_t r) {
+
+ ///Reserve storage in advance for the builder
+
+ ///If you know an reasonable upper bound of the number of the edges
+ ///to add, using this function you can speed up the building.
+ void reserve(size_t r) {
front.reserve(r);
back.reserve(r);
}
More information about the Lemon-commits
mailing list