diff options
author | Gedare Bloom <gedare@rtems.org> | 2012-03-04 11:42:08 -0500 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2012-03-04 11:42:08 -0500 |
commit | 41d33b90306ae6a12b0bb0c7466bf128aa7354bd (patch) | |
tree | c1fa541a733d51db02b7b6e8eb8019377f4dc5f8 /cpukit/score/src/rbtreeextract.c | |
parent | PR2034: sprbtree01: predecessor/successor imprecision (diff) | |
download | rtems-41d33b90306ae6a12b0bb0c7466bf128aa7354bd.tar.bz2 |
score: Add _RBTree_Opposite_direction.
Add a red-black tree helper method to ease obtaining the direction opposite
to the current direction. Useful for manipulating and traversing an rbtree.
Diffstat (limited to 'cpukit/score/src/rbtreeextract.c')
-rw-r--r-- | cpukit/score/src/rbtreeextract.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cpukit/score/src/rbtreeextract.c b/cpukit/score/src/rbtreeextract.c index ecbda18252..407136164e 100644 --- a/cpukit/score/src/rbtreeextract.c +++ b/cpukit/score/src/rbtreeextract.c @@ -50,7 +50,7 @@ static void _RBTree_Extract_validate_unprotected( sibling->color = RBT_BLACK; dir = the_node != parent->child[0]; _RBTree_Rotate(parent, dir); - sibling = parent->child[!dir]; + sibling = parent->child[_RBTree_Opposite_direction(dir)]; } /* sibling is black, see if both of its children are also black. */ @@ -72,15 +72,15 @@ static void _RBTree_Extract_validate_unprotected( * Then switch the sibling and parent colors, and rotate through parent. */ dir = the_node != parent->child[0]; - if (!_RBTree_Is_red(sibling->child[!dir])) { + if (!_RBTree_Is_red(sibling->child[_RBTree_Opposite_direction(dir)])) { sibling->color = RBT_RED; sibling->child[dir]->color = RBT_BLACK; - _RBTree_Rotate(sibling, !dir); - sibling = parent->child[!dir]; + _RBTree_Rotate(sibling, _RBTree_Opposite_direction(dir)); + sibling = parent->child[_RBTree_Opposite_direction(dir)]; } sibling->color = parent->color; parent->color = RBT_BLACK; - sibling->child[!dir]->color = RBT_BLACK; + sibling->child[_RBTree_Opposite_direction(dir)]->color = RBT_BLACK; _RBTree_Rotate(parent, dir); break; /* done */ } |