- Changes in doc (spell check).
- SmallGraph is a class instead of being a typedef. (For the sake of doxygen.)
2 #ifndef LEMON_ITERABLE_GRAPH_EXTENDER_H
3 #define LEMON_ITERABLE_GRAPH_EXTENDER_H
5 #include <lemon/invalid.h>
9 template <typename _Base>
10 class IterableGraphExtender : public _Base {
13 typedef IterableGraphExtender<_Base> Graph;
17 typedef typename Parent::Node Node;
18 typedef typename Parent::Edge Edge;
21 class NodeIt : public Node {
27 NodeIt(Invalid i) : Node(i) { }
29 explicit NodeIt(const Graph& _graph) : Node(), graph(&_graph) {
30 _graph.first(*static_cast<Node*>(this));
33 NodeIt(const Graph& _graph, const Node& node)
34 : Node(node), graph(&_graph) {}
36 NodeIt& operator++() {
44 class EdgeIt : public Edge {
50 EdgeIt(Invalid i) : Edge(i) { }
52 explicit EdgeIt(const Graph& _graph) : Edge(), graph(&_graph) {
53 _graph.first(*static_cast<Edge*>(this));
56 EdgeIt(const Graph& _graph, const Edge& e) :
57 Edge(e), graph(&_graph) { }
59 EdgeIt& operator++() {
67 class OutEdgeIt : public Edge {
73 OutEdgeIt(Invalid i) : Edge(i) { }
75 OutEdgeIt(const Graph& _graph, const Node& node)
76 : Edge(), graph(&_graph) {
77 _graph.firstOut(*this, node);
80 OutEdgeIt(const Graph& _graph, const Edge& edge)
81 : Edge(edge), graph(&_graph) {}
83 OutEdgeIt& operator++() {
84 graph->nextOut(*this);
91 class InEdgeIt : public Edge {
97 InEdgeIt(Invalid i) : Edge(i) { }
99 InEdgeIt(const Graph& _graph, const Node& node)
100 : Edge(), graph(&_graph) {
101 _graph.firstIn(*this, node);
104 InEdgeIt(const Graph& _graph, const Edge& edge) :
105 Edge(edge), graph(&_graph) {}
107 InEdgeIt& operator++() {
108 graph->nextIn(*this);
118 /// \todo When (and if) we change the iterators concept to use operator*,
119 /// then the following shadowed methods will become superfluous.
120 /// But for now these are important safety measures.
122 void first(NodeIt &) const;
123 void first(EdgeIt &) const;
124 void first(OutEdgeIt &) const;
125 void first(InEdgeIt &) const;
131 #endif // LEMON_GRAPH_EXTENDER_H