# HG changeset patch # User klao # Date 1083073454 0 # Node ID 178fb74b22d1fabe58e8869cc1d37b1eb4ede1ad # Parent 267dfa567ad3664bae04c2d8310eb8ad8a471ed5 * list_graph.h: - node_item and edge_item are structs and not classes - operator<< is inline diff -r 267dfa567ad3 -r 178fb74b22d1 src/work/list_graph.h --- a/src/work/list_graph.h Tue Apr 27 13:35:09 2004 +0000 +++ b/src/work/list_graph.h Tue Apr 27 13:44:14 2004 +0000 @@ -17,8 +17,8 @@ } class ListGraph { - class node_item; - class edge_item; + struct node_item; + struct edge_item; public: class Node; class NodeIt; @@ -84,20 +84,7 @@ node_item* _first_node; node_item* _last_node; - class node_item { - friend class ListGraph; - template friend class NodeMap; - - friend class Node; - friend class NodeIt; - friend class Edge; - friend class EdgeIt; - friend class OutEdgeIt; - friend class InEdgeIt; - friend class SymEdgeIt; - friend std::ostream& operator<<(std::ostream& os, const Node& i); - friend std::ostream& operator<<(std::ostream& os, const Edge& i); - //ListGraph* G; + struct node_item { int id; edge_item* _first_out_edge; edge_item* _last_out_edge; @@ -105,23 +92,9 @@ edge_item* _last_in_edge; node_item* _next_node; node_item* _prev_node; - public: - node_item() { } }; - class edge_item { - friend class ListGraph; - template friend class EdgeMap; - - friend class Node; - friend class NodeIt; - friend class Edge; - friend class EdgeIt; - friend class OutEdgeIt; - friend class InEdgeIt; - friend class SymEdgeIt; - friend std::ostream& operator<<(std::ostream& os, const Edge& i); - //ListGraph* G; + struct edge_item { int id; node_item* _tail; node_item* _head; @@ -129,8 +102,6 @@ edge_item* _prev_out; edge_item* _next_in; edge_item* _prev_in; - public: - edge_item() { } }; node_item* _add_node() { @@ -546,16 +517,20 @@ }; }; + inline std::ostream& operator<<(std::ostream& os, const ListGraph::Node& i) { if (i.valid()) - os << i.node->id; + os << i.node->id; else os << "invalid"; return os; } + + inline std::ostream& operator<<(std::ostream& os, const ListGraph::Edge& i) { if (i.valid()) - os << "(" << i.edge->_tail->id << "--" << i.edge->id << "->" << i.edge->_head->id << ")"; + os << "(" << i.tailNode() << "--" << i.edge->id << "->" + << i.headNode() << ")"; else os << "invalid"; return os;