Permalink
Browse files

Cosmetic comment update.

  • Loading branch information...
1 parent be39f03 commit 1ebaed257db2f488b3a74c98aef042132afb175d @nahi committed Feb 5, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/red_black_tree.rb
View
@@ -307,12 +307,15 @@ def rotate_right
private
# trying to rebalance when the left sub-tree is 1 level higher than the right
+ # precondition: self is black and @left is red
def rebalance_for_left_insert
ret = self
if @right.red?
+ # pull-up red nodes and let the parent rebalance (see precondition)
@color = :RED
@left.color = @right.color = :BLACK
else
+ # move 1 black from the left to the right by single/double rotation
if @left.right.red?
@left = @left.rotate_left
end
@@ -322,6 +325,7 @@ def rebalance_for_left_insert
end
# trying to rebalance when the right sub-tree is 1 level higher than the left
+ # See rebalance_for_left_insert.
def rebalance_for_right_insert
ret = self
if @left.red?

0 comments on commit 1ebaed2

Please sign in to comment.