equal
deleted
inserted
replaced
3 |
3 |
4 template <class G, class K> |
4 template <class G, class K> |
5 class EdgeMapBase { |
5 class EdgeMapBase { |
6 public: |
6 public: |
7 typedef G Graph; |
7 typedef G Graph; |
|
8 |
8 typedef K KeyType; |
9 typedef K KeyType; |
9 |
10 |
|
11 EdgeMapBase() : graph(0) {} |
|
12 EdgeMapBase(Graph& g) : graph(&g) { |
|
13 graph->edge_maps.add(*this); |
|
14 } |
10 |
15 |
11 MapBase() : graph(0) {} |
16 virtual ~EdgeMapBase() { |
12 MapBase(Graph& g) : graph(&g) {graph.edge_maps.add(*this);} |
17 if (graph) { |
13 |
18 graph.edge_maps.erase(*this); |
14 virtual ~MapBase() {graph.edge_maps.erase(*this);} |
19 } |
15 |
20 } |
|
21 |
16 protected: |
22 protected: |
17 |
23 |
18 Graph* graph; |
24 Graph* graph; |
19 |
25 |
20 int graph_index; |
26 int graph_index; |
21 |
27 |
|
28 void init() { |
|
29 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) { |
|
30 add(it); |
|
31 } |
|
32 } |
|
33 |
|
34 void destroy() { |
|
35 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) { |
|
36 erase(it); |
|
37 } |
|
38 } |
22 |
39 |
23 virtual void add(const KeyType&) = 0; |
40 virtual void add(const KeyType&) = 0; |
24 virtual void erase(const KeyType&) = 0; |
41 virtual void erase(const KeyType&) = 0; |
25 |
42 |
26 friend class Graph; |
43 friend class Graph; |