# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1346263445 -7200 # Node ID fcb7a71a22c1cd5d12361610013dcbf5e1cb4b8a # Parent 9a1825df8418e6cd1aaebe6a455c0b4d551ecd1d Make it possible to turn off asserting for the RBTree template header. diff -r 9a1825df8418 -r fcb7a71a22c1 RBTree.hpp --- 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 -#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 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(); } }