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.
     1 #ifndef EDGE_MAP_BASE_H
     2 #define EDGE_MAP_BASE_H
     3 
     4 template <class G, class K>
     5 class EdgeMapBase {
     6 public:
     7 	typedef G Graph;
     8 
     9 	typedef K KeyType;
    10 	
    11 	EdgeMapBase() : graph(0) {}
    12 	EdgeMapBase(Graph& g) : graph(&g) {
    13 		graph->edge_maps.add(*this);
    14 	}
    15 
    16 	virtual ~EdgeMapBase() {
    17 		if (graph) {
    18 			graph.edge_maps.erase(*this);
    19 		}
    20 	}
    21 	
    22 protected:
    23 	
    24 	Graph* graph;
    25 
    26 	int graph_index;
    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 	}
    39 	
    40 	virtual void add(const KeyType&) = 0;
    41 	virtual void erase(const KeyType&) = 0;
    42 
    43 	friend class Graph;
    44 };
    45 
    46 #endif