author | marci |
Fri, 16 Apr 2004 13:05:08 +0000 | |
changeset 338 | e8725f30dd98 |
parent 262 | 60de0f16a4a1 |
child 340 | a2ce3c4780b7 |
permissions | -rw-r--r-- |
1 #ifndef EDGE_MAP_BASE_H
2 #define EDGE_MAP_BASE_H
4 template <class G, class K>
5 class EdgeMapBase {
6 public:
7 typedef G Graph;
9 typedef K KeyType;
11 EdgeMapBase() : graph(0) {}
12 EdgeMapBase(Graph& g) : graph(&g) {
13 graph->edge_maps.add(*this);
14 }
16 virtual ~EdgeMapBase() {
17 if (graph) {
18 graph.edge_maps.erase(*this);
19 }
20 }
22 protected:
24 Graph* graph;
26 int graph_index;
28 void init() {
29 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
30 add(it);
31 }
32 }
34 void destroy() {
35 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
36 erase(it);
37 }
38 }
40 virtual void add(const KeyType&) = 0;
41 virtual void erase(const KeyType&) = 0;
43 friend class Graph;
44 };
46 #endif