author | athos |
Thu, 02 Jun 2005 14:43:45 +0000 | |
changeset 1443 | 70781827eb2f |
parent 1414 | 01d9d6bc1284 |
child 1627 | 3fd1ba6e9872 |
permissions | -rw-r--r-- |
klao@946 | 1 |
// -*- c++ -*- |
klao@946 | 2 |
|
klao@946 | 3 |
#ifndef LEMON_ERASABLE_GRAPH_EXTENDER_H |
klao@946 | 4 |
#define LEMON_ERASABLE_GRAPH_EXTENDER_H |
klao@946 | 5 |
|
deba@1414 | 6 |
#include <vector> |
deba@1414 | 7 |
|
klao@946 | 8 |
#include <lemon/invalid.h> |
klao@946 | 9 |
|
klao@946 | 10 |
|
klao@946 | 11 |
namespace lemon { |
klao@946 | 12 |
|
klao@946 | 13 |
template <typename _Base> |
klao@946 | 14 |
class ErasableGraphExtender : public _Base { |
klao@946 | 15 |
public: |
klao@946 | 16 |
|
klao@946 | 17 |
typedef ErasableGraphExtender Graph; |
klao@946 | 18 |
typedef _Base Parent; |
klao@946 | 19 |
|
klao@946 | 20 |
typedef typename Parent::Node Node; |
klao@946 | 21 |
typedef typename Parent::Edge Edge; |
klao@946 | 22 |
|
klao@946 | 23 |
void erase(const Node& node) { |
klao@946 | 24 |
Edge edge; |
klao@946 | 25 |
Parent::firstOut(edge, node); |
klao@946 | 26 |
while (edge != INVALID ) { |
klao@946 | 27 |
erase(edge); |
klao@946 | 28 |
Parent::firstOut(edge, node); |
klao@946 | 29 |
} |
klao@946 | 30 |
|
klao@946 | 31 |
Parent::firstIn(edge, node); |
klao@946 | 32 |
while (edge != INVALID ) { |
klao@946 | 33 |
erase(edge); |
klao@946 | 34 |
Parent::firstIn(edge, node); |
klao@946 | 35 |
} |
klao@946 | 36 |
|
deba@1039 | 37 |
Parent::getNotifier(Node()).erase(node); |
klao@946 | 38 |
Parent::erase(node); |
klao@946 | 39 |
} |
klao@946 | 40 |
|
klao@946 | 41 |
void erase(const Edge& edge) { |
deba@1039 | 42 |
Parent::getNotifier(Edge()).erase(edge); |
klao@946 | 43 |
Parent::erase(edge); |
klao@946 | 44 |
} |
klao@946 | 45 |
|
klao@946 | 46 |
}; |
klao@946 | 47 |
|
klao@1022 | 48 |
template <typename _Base> |
klao@1022 | 49 |
class ErasableUndirGraphExtender : public _Base { |
klao@1022 | 50 |
public: |
klao@1022 | 51 |
|
klao@1022 | 52 |
typedef ErasableUndirGraphExtender Graph; |
klao@1022 | 53 |
typedef _Base Parent; |
klao@1022 | 54 |
|
klao@1022 | 55 |
typedef typename Parent::Node Node; |
klao@1022 | 56 |
typedef typename Parent::UndirEdge UndirEdge; |
klao@1022 | 57 |
typedef typename Parent::Edge Edge; |
klao@1022 | 58 |
|
klao@1022 | 59 |
void erase(const Node& node) { |
klao@1022 | 60 |
Edge edge; |
klao@1022 | 61 |
Parent::firstOut(edge, node); |
klao@1022 | 62 |
while (edge != INVALID ) { |
klao@1022 | 63 |
erase(edge); |
klao@1022 | 64 |
Parent::firstOut(edge, node); |
klao@1022 | 65 |
} |
klao@1022 | 66 |
|
deba@1039 | 67 |
Parent::getNotifier(Node()).erase(node); |
klao@1022 | 68 |
Parent::erase(node); |
klao@1022 | 69 |
} |
klao@1022 | 70 |
|
klao@1022 | 71 |
void erase(const UndirEdge& uedge) { |
deba@1414 | 72 |
std::vector<Edge> edges; |
deba@1414 | 73 |
edges.push_back(Edge(uedge,true)); |
deba@1414 | 74 |
edges.push_back(Edge(uedge,false)); |
deba@1414 | 75 |
Parent::getNotifier(Edge()).erase(edges); |
deba@1039 | 76 |
Parent::getNotifier(UndirEdge()).erase(uedge); |
klao@1022 | 77 |
Parent::erase(uedge); |
klao@1022 | 78 |
} |
klao@1022 | 79 |
|
klao@1022 | 80 |
}; |
klao@1022 | 81 |
|
klao@946 | 82 |
} |
klao@946 | 83 |
|
klao@946 | 84 |
#endif |