gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Get rid of exceptions in Preflow
0 1 0
default
1 file changed with 4 insertions and 14 deletions:
↑ Collapse diff ↑
Ignore white space 24 line context
... ...
@@ -10,25 +10,24 @@
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_PREFLOW_H
20 20
#define LEMON_PREFLOW_H
21 21

	
22
#include <lemon/error.h>
23 22
#include <lemon/tolerance.h>
24 23
#include <lemon/elevator.h>
25 24

	
26 25
/// \file
27 26
/// \ingroup max_flow
28 27
/// \brief Implementation of the preflow algorithm.
29 28

	
30 29
namespace lemon {
31 30

	
32 31
  /// \brief Default traits class of Preflow class.
33 32
  ///
34 33
  /// Default traits class of Preflow class.
... ...
@@ -123,35 +122,24 @@
123 122
  class Preflow {
124 123
  public:
125 124

	
126 125
    typedef _Traits Traits;
127 126
    typedef typename Traits::Digraph Digraph;
128 127
    typedef typename Traits::CapacityMap CapacityMap;
129 128
    typedef typename Traits::Value Value;
130 129

	
131 130
    typedef typename Traits::FlowMap FlowMap;
132 131
    typedef typename Traits::Elevator Elevator;
133 132
    typedef typename Traits::Tolerance Tolerance;
134 133

	
135
    /// \brief \ref Exception for uninitialized parameters.
136
    ///
137
    /// This error represents problems in the initialization
138
    /// of the parameters of the algorithms.
139
    class UninitializedParameter : public lemon::Exception {
140
    public:
141
      virtual const char* what() const throw() {
142
        return "lemon::Preflow::UninitializedParameter";
143
      }
144
    };
145

	
146 134
  private:
147 135

	
148 136
    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
149 137

	
150 138
    const Digraph& _graph;
151 139
    const CapacityMap* _capacity;
152 140

	
153 141
    int _node_num;
154 142

	
155 143
    Node _source, _target;
156 144

	
157 145
    FlowMap* _flow;
... ...
@@ -199,45 +187,47 @@
199 187
  public:
200 188

	
201 189
    typedef Preflow Create;
202 190

	
203 191
    ///\name Named template parameters
204 192

	
205 193
    ///@{
206 194

	
207 195
    template <typename _FlowMap>
208 196
    struct DefFlowMapTraits : public Traits {
209 197
      typedef _FlowMap FlowMap;
210 198
      static FlowMap *createFlowMap(const Digraph&) {
211
        throw UninitializedParameter();
199
        LEMON_ASSERT(false, "FlowMap is not initialized");
200
        return 0; // ignore warnings
212 201
      }
213 202
    };
214 203

	
215 204
    /// \brief \ref named-templ-param "Named parameter" for setting
216 205
    /// FlowMap type
217 206
    ///
218 207
    /// \ref named-templ-param "Named parameter" for setting FlowMap
219 208
    /// type
220 209
    template <typename _FlowMap>
221 210
    struct DefFlowMap
222 211
      : public Preflow<Digraph, CapacityMap, DefFlowMapTraits<_FlowMap> > {
223 212
      typedef Preflow<Digraph, CapacityMap,
224 213
                      DefFlowMapTraits<_FlowMap> > Create;
225 214
    };
226 215

	
227 216
    template <typename _Elevator>
228 217
    struct DefElevatorTraits : public Traits {
229 218
      typedef _Elevator Elevator;
230 219
      static Elevator *createElevator(const Digraph&, int) {
231
        throw UninitializedParameter();
220
        LEMON_ASSERT(false, "Elevator is not initialized");
221
        return 0; // ignore warnings
232 222
      }
233 223
    };
234 224

	
235 225
    /// \brief \ref named-templ-param "Named parameter" for setting
236 226
    /// Elevator type
237 227
    ///
238 228
    /// \ref named-templ-param "Named parameter" for setting Elevator
239 229
    /// type
240 230
    template <typename _Elevator>
241 231
    struct DefElevator
242 232
      : public Preflow<Digraph, CapacityMap, DefElevatorTraits<_Elevator> > {
243 233
      typedef Preflow<Digraph, CapacityMap,
0 comments (0 inline)