Browse Source

ensure that a grandparent exists when it is involved in the ballance

1.0.2
Georg Hopp 11 years ago
parent
commit
db5f9d43f7
  1. 18
      include/tr/tree_macros.h

18
include/tr/tree_macros.h

@ -263,14 +263,16 @@ typedef enum {rbBlack=1, rbRed=2} TR_rbColor;
TR_TREE_ROTATE(left, (root), (node)->parent->parent); \
}
#define TR_TREE_BALANCE_INSERT(root, node) \
while (1) { \
TR_TREE_BALANCE_INSERT_CASE1((node)) \
TR_TREE_BALANCE_INSERT_CASE2((node)) \
TR_TREE_BALANCE_INSERT_CASE3((node)) \
TR_TREE_BALANCE_INSERT_CASE4((root), (node)) \
TR_TREE_BALANCE_INSERT_CASE5((root), (node)) \
break; \
#define TR_TREE_BALANCE_INSERT(root, node) \
while (1) { \
TR_TREE_BALANCE_INSERT_CASE1((node)) \
TR_TREE_BALANCE_INSERT_CASE2((node)) \
if (NULL != (node)->parent->parent) { \
TR_TREE_BALANCE_INSERT_CASE3((node)) \
TR_TREE_BALANCE_INSERT_CASE4((root), (node)) \
TR_TREE_BALANCE_INSERT_CASE5((root), (node)) \
} \
break; \
}
#endif // __TR_TREE_MACROS_H__

Loading…
Cancel
Save