Class: DS::RedBlackTree::Node
- Inherits:
-
Object
- Object
- DS::RedBlackTree::Node
- Defined in:
- lib/ds/trees/red_black_tree/node.rb
Overview
Red Black Tree Node
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#data ⇒ Object
Returns the value of attribute data.
-
#key ⇒ Object
Returns the value of attribute key.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(key, value, color) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(key, value, color) ⇒ Node
Returns a new instance of Node.
8 9 10 11 12 13 14 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 8 def initialize(key, value, color) @key = key @data = value @color = color @left = nil @right = nil end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 6 def color @color end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 6 def data @data end |
#key ⇒ Object
Returns the value of attribute key.
6 7 8 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 6 def key @key end |
#left ⇒ Object
Returns the value of attribute left.
6 7 8 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 6 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 6 def right @right end |
Instance Method Details
#children ⇒ Object
16 17 18 |
# File 'lib/ds/trees/red_black_tree/node.rb', line 16 def children [@left, @right] end |