[Lemon-commits] [lemon_svn] deba: r2508 - in hugo/trunk/lemon: bits concept
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:53:10 CET 2006
Author: deba
Date: Tue Jan 31 21:04:36 2006
New Revision: 2508
Modified:
hugo/trunk/lemon/bits/iterable_graph_extender.h
hugo/trunk/lemon/concept/bpugraph.h
Log:
Revising the bpugraph concept
We need a public but very limited ANode and BNode class
It can be used with ItemSetTraits and with some special maps
By example:
DescriptorMap<Graph, ANode>
InvertableMap<Graph, ANode, string>
IterableBoolMap<Graph, ANode>
IterableIntMap<Graph, ANode>
IterableValueMap<Graph, ANode, string>
Modified: hugo/trunk/lemon/bits/iterable_graph_extender.h
==============================================================================
--- hugo/trunk/lemon/bits/iterable_graph_extender.h (original)
+++ hugo/trunk/lemon/bits/iterable_graph_extender.h Tue Jan 31 21:04:36 2006
@@ -303,7 +303,7 @@
};
- class ANodeIt : public Node {
+ class ANodeIt : public ANode {
friend class IterableBpUGraphExtender;
const Graph* graph;
public:
@@ -325,7 +325,7 @@
}
};
- class BNodeIt : public Node {
+ class BNodeIt : public BNode {
friend class IterableBpUGraphExtender;
const Graph* graph;
public:
Modified: hugo/trunk/lemon/concept/bpugraph.h
==============================================================================
--- hugo/trunk/lemon/concept/bpugraph.h (original)
+++ hugo/trunk/lemon/concept/bpugraph.h Tue Jan 31 21:04:36 2006
@@ -56,9 +56,11 @@
/// as an undirected graph and consequently as a static graph.
///
/// The bipartite graph stores two types of nodes which are named
- /// ANode and BNode. Even so the graph type does not contain ANode
- /// and BNode classes, becaue the nodes can be accessed just with the
- /// common Node class.
+ /// ANode and BNode. The graph type contains two types ANode and BNode
+ /// which are inherited from Node type. Moreover they have
+ /// constructor which converts Node to either ANode or BNode when it is
+ /// possible. Therefor everywhere the Node type can be used instead of
+ /// ANode and BNode. So the usage of the ANode and BNode is suggested.
///
/// The iteration on the partition can be done with the ANodeIt and
/// BNodeIt classes. The node map can be used to map values to the nodes
@@ -122,6 +124,120 @@
bool operator<(Node) const { return false; }
};
+
+ /// \brief The base type of anode iterators,
+ /// or in other words, the trivial anode iterator.
+ ///
+ /// This is the base type of each anode iterator,
+ /// thus each kind of anode iterator converts to this.
+ /// More precisely each kind of node iterator should be inherited
+ /// from the trivial anode iterator. The ANode class should be used
+ /// only in special cases. Usually the Node type should be used insted
+ /// of it.
+ class ANode {
+ public:
+ /// Default constructor
+
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ ANode() { }
+ /// Copy constructor.
+
+ /// Copy constructor.
+ ///
+ ANode(const ANode&) { }
+
+ /// Construct the same node as ANode.
+
+ /// Construct the same node as ANode. It may throws assertion
+ /// when the given node is from the BNode set.
+ ANode(const Node&) { }
+
+ /// Invalid constructor \& conversion.
+
+ /// This constructor initializes the iterator to be invalid.
+ /// \sa Invalid for more details.
+ ANode(Invalid) { }
+ /// Equality operator
+
+ /// Two iterators are equal if and only if they point to the
+ /// same object or both are invalid.
+ bool operator==(ANode) const { return true; }
+
+ /// Inequality operator
+
+ /// \sa operator==(ANode n)
+ ///
+ bool operator!=(ANode) const { return true; }
+
+ /// Artificial ordering operator.
+
+ /// To allow the use of graph descriptors as key type in std::map or
+ /// similar associative container we require this.
+ ///
+ /// \note This operator only have to define some strict ordering of
+ /// the items; this order has nothing to do with the iteration
+ /// ordering of the items.
+ bool operator<(ANode) const { return false; }
+
+ };
+
+ /// \brief The base type of bnode iterators,
+ /// or in other words, the trivial bnode iterator.
+ ///
+ /// This is the base type of each anode iterator,
+ /// thus each kind of anode iterator converts to this.
+ /// More precisely each kind of node iterator should be inherited
+ /// from the trivial anode iterator. The BNode class should be used
+ /// only in special cases. Usually the Node type should be used insted
+ /// of it.
+ class BNode {
+ public:
+ /// Default constructor
+
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ BNode() { }
+ /// Copy constructor.
+
+ /// Copy constructor.
+ ///
+ BNode(const BNode&) { }
+
+ /// Construct the same node as BNode.
+
+ /// Construct the same node as BNode. It may throws assertion
+ /// when the given node is from the ANode set.
+ BNode(const Node&) { }
+
+ /// Invalid constructor \& conversion.
+
+ /// This constructor initializes the iterator to be invalid.
+ /// \sa Invalid for more details.
+ BNode(Invalid) { }
+ /// Equality operator
+
+ /// Two iterators are equal if and only if they point to the
+ /// same object or both are invalid.
+ bool operator==(BNode) const { return true; }
+
+ /// Inequality operator
+
+ /// \sa operator==(BNode n)
+ ///
+ bool operator!=(BNode) const { return true; }
+
+ /// Artificial ordering operator.
+
+ /// To allow the use of graph descriptors as key type in std::map or
+ /// similar associative container we require this.
+ ///
+ /// \note This operator only have to define some strict ordering of
+ /// the items; this order has nothing to do with the iteration
+ /// ordering of the items.
+ bool operator<(BNode) const { return false; }
+
+ };
/// This iterator goes through each node.
@@ -177,7 +293,7 @@
/// int count=0;
/// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count;
/// \endcode
- class ANodeIt : public Node {
+ class ANodeIt : public ANode {
public:
/// Default constructor
@@ -222,7 +338,7 @@
/// int count=0;
/// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count;
/// \endcode
- class BNodeIt : public Node {
+ class BNodeIt : public BNode {
public:
/// Default constructor
More information about the Lemon-commits
mailing list