(none)
authordeba
Fri, 16 Apr 2004 12:13:07 +0000
changeset 3368ff3b3e05478
parent 335 999eb3cd7b49
child 337 6e1b7efa577f
(none)
src/work/deba/edge_map_base.h
src/work/deba/node_map_base.h
     1.1 --- a/src/work/deba/edge_map_base.h	Fri Apr 16 08:26:00 2004 +0000
     1.2 +++ b/src/work/deba/edge_map_base.h	Fri Apr 16 12:13:07 2004 +0000
     1.3 @@ -5,20 +5,37 @@
     1.4  class EdgeMapBase {
     1.5  public:
     1.6  	typedef G Graph;
     1.7 +
     1.8  	typedef K KeyType;
     1.9  	
    1.10 +	EdgeMapBase() : graph(0) {}
    1.11 +	EdgeMapBase(Graph& g) : graph(&g) {
    1.12 +		graph->edge_maps.add(*this);
    1.13 +	}
    1.14  
    1.15 -	MapBase() : graph(0) {}
    1.16 -	MapBase(Graph& g) : graph(&g) {graph.edge_maps.add(*this);}
    1.17 -
    1.18 -	virtual ~MapBase() {graph.edge_maps.erase(*this);}	
    1.19 -
    1.20 +	virtual ~EdgeMapBase() {
    1.21 +		if (graph) {
    1.22 +			graph.edge_maps.erase(*this);
    1.23 +		}
    1.24 +	}
    1.25 +	
    1.26  protected:
    1.27  	
    1.28  	Graph* graph;
    1.29  
    1.30  	int graph_index;
    1.31  	
    1.32 +	void init() {
    1.33 +		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
    1.34 +			add(it);
    1.35 +		}
    1.36 +	}
    1.37 +	
    1.38 +	void destroy() {
    1.39 +		for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
    1.40 +			erase(it);
    1.41 +		}
    1.42 +	}
    1.43  	
    1.44  	virtual void add(const KeyType&) = 0;
    1.45  	virtual void erase(const KeyType&) = 0;
     2.1 --- a/src/work/deba/node_map_base.h	Fri Apr 16 08:26:00 2004 +0000
     2.2 +++ b/src/work/deba/node_map_base.h	Fri Apr 16 12:13:07 2004 +0000
     2.3 @@ -8,18 +8,34 @@
     2.4  
     2.5  	typedef K KeyType;
     2.6  	
     2.7 +	NodeMapBase() : graph(0) {}
     2.8 +	NodeMapBase(Graph& g) : graph(&g) {
     2.9 +		graph->node_maps.add(*this);
    2.10 +	}
    2.11  
    2.12 -	MapBase() : graph(0) {}
    2.13 -	MapBase(Graph& g) : graph(&g) {graph.node_maps.add(*this);}
    2.14 -
    2.15 -	virtual ~MapBase() {graph.node_maps.erase(*this);}	
    2.16 -
    2.17 +	virtual ~NodeMapBase() {
    2.18 +		if (graph) {
    2.19 +			graph.node_maps.erase(*this);
    2.20 +		}
    2.21 +	}
    2.22 +	
    2.23  protected:
    2.24  	
    2.25  	Graph* graph;
    2.26  
    2.27  	int graph_index;
    2.28  	
    2.29 +	void init() {
    2.30 +		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    2.31 +			add(it);
    2.32 +		}
    2.33 +	}
    2.34 +	
    2.35 +	void destroy() {
    2.36 +		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    2.37 +			erase(it);
    2.38 +		}
    2.39 +	}
    2.40  	
    2.41  	virtual void add(const KeyType&) = 0;
    2.42  	virtual void erase(const KeyType&) = 0;