Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332395
b: refs/heads/master
c: 7ce6ff9
h: refs/heads/master
i:
  332393: 422fd5d
  332391: 7966a2f
v: v3
  • Loading branch information
Michel Lespinasse authored and Linus Torvalds committed Oct 9, 2012
1 parent 3dd9f96 commit a810d5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6280d2356fd8ad0936a63c10dc1e6accf48d0c61
refs/heads/master: 7ce6ff9e5de99e7b72019c7de82fb438fe1dc5a0
42 changes: 23 additions & 19 deletions trunk/lib/rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
child = node->rb_right;
else if (!node->rb_right)
child = node->rb_left;
else
{
else {
struct rb_node *old = node, *left;

node = node->rb_right;
Expand Down Expand Up @@ -406,17 +405,15 @@ void rb_erase(struct rb_node *node, struct rb_root *root)

if (child)
rb_set_parent(child, parent);
if (parent)
{
if (parent) {
if (parent->rb_left == node)
parent->rb_left = child;
else
parent->rb_right = child;
}
else
} else
root->rb_node = child;

color:
color:
if (color == RB_BLACK)
__rb_erase_color(child, parent, root);
}
Expand Down Expand Up @@ -529,21 +526,24 @@ struct rb_node *rb_next(const struct rb_node *node)
if (RB_EMPTY_NODE(node))
return NULL;

/* If we have a right-hand child, go down and then left as far
as we can. */
/*
* If we have a right-hand child, go down and then left as far
* as we can.
*/
if (node->rb_right) {
node = node->rb_right;
while (node->rb_left)
node=node->rb_left;
return (struct rb_node *)node;
}

/* No right-hand children. Everything down and left is
smaller than us, so any 'next' node must be in the general
direction of our parent. Go up the tree; any time the
ancestor is a right-hand child of its parent, keep going
up. First time it's a left-hand child of its parent, said
parent is our 'next' node. */
/*
* No right-hand children. Everything down and left is smaller than us,
* so any 'next' node must be in the general direction of our parent.
* Go up the tree; any time the ancestor is a right-hand child of its
* parent, keep going up. First time it's a left-hand child of its
* parent, said parent is our 'next' node.
*/
while ((parent = rb_parent(node)) && node == parent->rb_right)
node = parent;

Expand All @@ -558,17 +558,21 @@ struct rb_node *rb_prev(const struct rb_node *node)
if (RB_EMPTY_NODE(node))
return NULL;

/* If we have a left-hand child, go down and then right as far
as we can. */
/*
* If we have a left-hand child, go down and then right as far
* as we can.
*/
if (node->rb_left) {
node = node->rb_left;
while (node->rb_right)
node=node->rb_right;
return (struct rb_node *)node;
}

/* No left-hand children. Go up till we find an ancestor which
is a right-hand child of its parent */
/*
* No left-hand children. Go up till we find an ancestor which
* is a right-hand child of its parent.
*/
while ((parent = rb_parent(node)) && node == parent->rb_left)
node = parent;

Expand Down

0 comments on commit a810d5a

Please sign in to comment.