Proper exception handling in the SmartEdgeSet
authordeba
Mon, 04 Sep 2006 11:09:59 +0000
changeset 2191ef3560193856
parent 2190 dd887831e9c1
child 2192 d6e4efb477d8
Proper exception handling in the SmartEdgeSet
lemon/edge_set.h
     1.1 --- a/lemon/edge_set.h	Mon Sep 04 11:09:13 2006 +0000
     1.2 +++ b/lemon/edge_set.h	Mon Sep 04 11:09:59 2006 +0000
     1.3 @@ -602,7 +602,7 @@
     1.4            Parent::OutEdgeIt(*this, node) == INVALID) {
     1.5          return;
     1.6        }
     1.7 -      throw UnsupportedOperation();
     1.8 +      throw typename NodesImplBase::Notifier::ImmediateDetach();
     1.9      }
    1.10      
    1.11      void clearNodes() {
    1.12 @@ -621,14 +621,22 @@
    1.13      protected:
    1.14  
    1.15        virtual void erase(const Node& node) {
    1.16 -	_edgeset.eraseNode(node);
    1.17 -	Parent::erase(node);
    1.18 +        try {
    1.19 +          _edgeset.eraseNode(node);
    1.20 +          Parent::erase(node);
    1.21 +        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
    1.22 +          Parent::clear();
    1.23 +        }
    1.24        }
    1.25        virtual void erase(const std::vector<Node>& nodes) {
    1.26 -        for (int i = 0; i < (int)nodes.size(); ++i) {
    1.27 -          _edgeset.eraseNode(nodes[i]);
    1.28 +        try {
    1.29 +          for (int i = 0; i < (int)nodes.size(); ++i) {
    1.30 +            _edgeset.eraseNode(nodes[i]);
    1.31 +          }
    1.32 +          Parent::erase(nodes);
    1.33 +        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
    1.34 +          Parent::clear();
    1.35          }
    1.36 -	Parent::erase(nodes);
    1.37        }
    1.38        virtual void clear() {
    1.39  	_edgeset.clearNodes();
    1.40 @@ -681,13 +689,6 @@
    1.41      
    1.42      typedef _Graph Graph;
    1.43  
    1.44 -    class UnsupportedOperation : public LogicError {
    1.45 -    public:
    1.46 -      virtual const char* what() const throw() {
    1.47 -        return "lemon::SmartUEdgeSet::UnsupportedOperation";
    1.48 -      }
    1.49 -    };
    1.50 -
    1.51    protected:
    1.52  
    1.53      typedef typename Parent::NodesImplBase NodesImplBase;
    1.54 @@ -696,7 +697,7 @@
    1.55        if (typename Parent::IncEdgeIt(*this, node) == INVALID) {
    1.56          return;
    1.57        }
    1.58 -      throw UnsupportedOperation();
    1.59 +      throw typename NodesImplBase::Notifier::ImmediateDetach();
    1.60      }
    1.61      
    1.62      void clearNodes() {
    1.63 @@ -715,14 +716,22 @@
    1.64      protected:
    1.65  
    1.66        virtual void erase(const Node& node) {
    1.67 -	_edgeset.eraseNode(node);
    1.68 -	Parent::erase(node);
    1.69 +        try {
    1.70 +          _edgeset.eraseNode(node);
    1.71 +          Parent::erase(node);
    1.72 +        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
    1.73 +          Parent::clear();
    1.74 +        }
    1.75        }
    1.76        virtual void erase(const std::vector<Node>& nodes) {
    1.77 -	for (int i = 0; i < (int)nodes.size(); ++i) {
    1.78 -	  _edgeset.eraseNode(nodes[i]);
    1.79 -	}
    1.80 -	Parent::erase(nodes);
    1.81 +        try {
    1.82 +          for (int i = 0; i < (int)nodes.size(); ++i) {
    1.83 +            _edgeset.eraseNode(nodes[i]);
    1.84 +          }
    1.85 +          Parent::erase(nodes);
    1.86 +        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
    1.87 +          Parent::clear();
    1.88 +        }
    1.89        }
    1.90        virtual void clear() {
    1.91  	_edgeset.clearNodes();