src/work/deba/edge_map_base.h
author marci
Fri, 16 Apr 2004 13:05:08 +0000
changeset 338 e8725f30dd98
parent 262 60de0f16a4a1
child 340 a2ce3c4780b7
permissions -rw-r--r--
kicsit takaritottam, es szepitettem es, es maga a csuda, de azer nem
teljesen mer' meg kell csinalni vele dolgokat.
deba@262
     1
#ifndef EDGE_MAP_BASE_H
deba@262
     2
#define EDGE_MAP_BASE_H
deba@262
     3
deba@262
     4
template <class G, class K>
deba@262
     5
class EdgeMapBase {
deba@262
     6
public:
deba@262
     7
	typedef G Graph;
deba@336
     8
deba@262
     9
	typedef K KeyType;
deba@262
    10
	
deba@336
    11
	EdgeMapBase() : graph(0) {}
deba@336
    12
	EdgeMapBase(Graph& g) : graph(&g) {
deba@336
    13
		graph->edge_maps.add(*this);
deba@336
    14
	}
deba@262
    15
deba@336
    16
	virtual ~EdgeMapBase() {
deba@336
    17
		if (graph) {
deba@336
    18
			graph.edge_maps.erase(*this);
deba@336
    19
		}
deba@336
    20
	}
deba@336
    21
	
deba@262
    22
protected:
deba@262
    23
	
deba@262
    24
	Graph* graph;
deba@262
    25
deba@262
    26
	int graph_index;
deba@262
    27
	
deba@336
    28
	void init() {
deba@336
    29
		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
deba@336
    30
			add(it);
deba@336
    31
		}
deba@336
    32
	}
deba@336
    33
	
deba@336
    34
	void destroy() {
deba@336
    35
		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
deba@336
    36
			erase(it);
deba@336
    37
		}
deba@336
    38
	}
deba@262
    39
	
deba@262
    40
	virtual void add(const KeyType&) = 0;
deba@262
    41
	virtual void erase(const KeyType&) = 0;
deba@262
    42
deba@262
    43
	friend class Graph;
deba@262
    44
};
deba@262
    45
deba@262
    46
#endif