Mercurial > dedupe
changeset 18:fcb7a71a22c1
Make it possible to turn off asserting for the RBTree template header.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Wed, 29 Aug 2012 20:04:05 +0200 |
| parents | 9a1825df8418 |
| children | 1ad6fa6dc039 |
| files | RBTree.hpp |
| diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/RBTree.hpp Tue Aug 28 19:15:33 2012 +0200 +++ b/RBTree.hpp Wed Aug 29 20:04:05 2012 +0200 @@ -7,14 +7,17 @@ #include <QtCore/QDebug> -#define CONSISTENCY_CHECKING 0 +#define CONSISTENCY_CHECKING 1 #if CONSISTENCY_CHECKING -#define CONSISTENCY_CHECK(n) assert(!n || (n)->consistent()) +#define RBTREE_ASSERT(X) assert(X) #else -#define CONSISTENCY_CHECK(n) +#define RBTREE_ASSERT(X) #endif +#define CONSISTENCY_CHECK(n) RBTREE_ASSERT(!n || (n)->consistent()) + + template<typename Data> class RBTree { private: @@ -79,14 +82,14 @@ void rotate_left() { RBTreeNode* Q = this->right; - assert(Q); + RBTREE_ASSERT(Q); // Set Q to be the new root. if (this->parent) { if (this->parent->left == this) { this->parent->left = Q; } else { - assert(this->parent->right == this); + RBTREE_ASSERT(this->parent->right == this); this->parent->right = Q; } } @@ -101,14 +104,14 @@ void rotate_right() { RBTreeNode* P = this->left; - assert(P); + RBTREE_ASSERT(P); //Set P to be the new root. if (this->parent) { if (this->parent->left == this) { this->parent->left = P; } else { - assert(this->parent->right == this); + RBTREE_ASSERT(this->parent->right == this); this->parent->right = P; } } @@ -131,7 +134,7 @@ if (this == this->parent->left) g->rotate_right(); else { - assert (this == this->parent->right); + RBTREE_ASSERT (this == this->parent->right); g->rotate_left(); } }
