Skip to content

Commit 555deb8

Browse files
committed
remove assert and exception macros
1 parent dd79826 commit 555deb8

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

include/maxplus/base/exception/exception.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,4 @@ class MPException : std::exception {
9999

100100
} // namespace MaxPlus
101101

102-
#define ASSERT(condition, msg) \
103-
{ \
104-
if (!(condition)) \
105-
throw MaxPlus::MPException(MaxPlus::MPString(__FILE__) + MaxPlus::MPString(":") + MaxPlus::MPString(__LINE__) + MaxPlus::MPString(": ") \
106-
+ MaxPlus::MPString(msg)); \
107-
}
108-
109-
#define EXCEPTION(msg, ...) \
110-
{ \
111-
char buf[1024]; \
112-
sprintf(&buf[0], msg, __VA_ARGS__); \
113-
throw MPException(buf); \
114-
}
115-
116102
#endif

src/base/analysis/mcm/mcmgraph.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@
4242
#include "base/analysis/mcm/mcmgraph.h"
4343
#include "base/analysis/mcm/mcm.h"
4444
#include "base/analysis/mcm/mcmyto.h"
45-
#include "base/base.h"
45+
#include <cassert>
46+
#include <map>
4647
#include <memory>
48+
#include <set>
49+
#include <vector>
50+
51+
4752

4853
namespace Graphs {
4954
/**
@@ -278,14 +283,16 @@ void addLongestDelayEdgesToMCMgraph(MCMgraph &g) {
278283
}
279284
}
280285

286+
namespace {
287+
281288
/**
282289
* getAdjacentNodes ()
283290
* The function returns a list with nodes directly reachable from
284291
* node a (in case transpose if false). If transpose is 'true', the
285292
* graph is transposed and the function returns a list with nodes
286293
* which are directly reachable from a in the transposed graph.
287294
*/
288-
static MCMnodeRefs getAdjacentNodes(const MCMnode &a, bool transpose) {
295+
MCMnodeRefs getAdjacentNodes(const MCMnode &a, bool transpose) {
289296
MCMnodeRefs node_refs;
290297

291298
if (!transpose) {
@@ -311,7 +318,7 @@ static MCMnodeRefs getAdjacentNodes(const MCMnode &a, bool transpose) {
311318
* order. Its order is set to -1. If all nodes have order -1, a nullptr pointer is
312319
* returned.
313320
*/
314-
static const MCMnode *getNextNode(MCMnodes &nodes, v_int &order) {
321+
const MCMnode *getNextNode(MCMnodes &nodes, v_int &order) {
315322
const MCMnode *a = nullptr;
316323
int orderA = -1;
317324

@@ -335,7 +342,7 @@ static const MCMnode *getNextNode(MCMnodes &nodes, v_int &order) {
335342
* dfsVisit ()
336343
* The visitor function of the DFS algorithm.
337344
*/
338-
static void dfsVisit(const MCMnode &u,
345+
void dfsVisit(const MCMnode &u,
339346
int &time,
340347
v_int &color,
341348
v_int &d,
@@ -367,6 +374,8 @@ static void dfsVisit(const MCMnode &u,
367374
f[u.id] = time;
368375
}
369376

377+
} // namespace
378+
370379
/**
371380
* dfsMCMgraph ()
372381
* The function performs a depth first search on the graph. The discover
@@ -470,7 +479,8 @@ treeVisitChildren(MCMgraph &g, std::vector<const MCMnode *> &pi, MCMnode *u, MCM
470479
break;
471480
}
472481
}
473-
ASSERT(v != nullptr, "There must always be a node v.");
482+
// There must always be a node v.
483+
assert((v != nullptr));
474484

475485
// Add node v to the component
476486
v->visible = true;

src/base/analysis/mcm/mcmyto.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <cfloat>
5454
#include <cstdint>
5555
#include <memory>
56+
#include <cassert>
5657

5758
namespace Graphs {
5859

@@ -470,7 +471,8 @@ class AlgYTO {
470471

471472
while (true) {
472473
min_a_ptr = GetMin();
473-
ASSERT(min_a_ptr != NILA, "No element on heap!");
474+
// should be element on heap
475+
assert((min_a_ptr != NILA));
474476

475477
*lambda = min_a_ptr->key;
476478
if (*lambda >= infty) {
@@ -757,7 +759,8 @@ class AlgYTO {
757759

758760
while (true) {
759761
min_a_ptr = GetMin();
760-
ASSERT(min_a_ptr != NILA, "No element on heap!");
762+
// there must be an element on the heap
763+
assert(min_a_ptr != NILA);
761764

762765
*lambda = min_a_ptr->key;
763766
if (*lambda >= infty) {

0 commit comments

Comments
 (0)