Class: LeftLeaningRedBlackTree::Tree
- Inherits:
-
Object
- Object
- LeftLeaningRedBlackTree::Tree
- Defined in:
- lib/left_leaning_red_black_tree.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #delete(key) ⇒ Object
-
#initialize ⇒ Tree
constructor
A new instance of Tree.
- #insert(key, payload) ⇒ Object
- #print_tree ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
5 6 7 |
# File 'lib/left_leaning_red_black_tree.rb', line 5 def root @root end |
Instance Method Details
#delete(key) ⇒ Object
16 17 18 19 |
# File 'lib/left_leaning_red_black_tree.rb', line 16 def delete(key) @root = @root.delete(key) @root.color = BLACK end |
#insert(key, payload) ⇒ Object
11 12 13 14 |
# File 'lib/left_leaning_red_black_tree.rb', line 11 def insert(key, payload) @root = @root.insert(key, payload) @root.color = BLACK end |
#print_tree ⇒ Object
21 22 23 |
# File 'lib/left_leaning_red_black_tree.rb', line 21 def print_tree root.print_node([@root], 1, @root.max_level) end |