Class: Lite::Containers::AvlTree::Node
- Inherits:
-
Object
- Object
- Lite::Containers::AvlTree::Node
- Defined in:
- lib/lite/containers/avl_tree/node.rb
Direct Known Subclasses
Interfaces::KeyExtractionStrategy::Explicit::Node, Interfaces::KeyExtractionStrategy::Implicit::Node
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, value) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #out ⇒ Object
Constructor Details
#initialize(key, value) ⇒ Node
Returns a new instance of Node.
16 17 18 19 20 21 22 |
# File 'lib/lite/containers/avl_tree/node.rb', line 16 def initialize(key, value) @key = key @value = value @height = 1 @left = nil @right = nil end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
8 9 10 |
# File 'lib/lite/containers/avl_tree/node.rb', line 8 def height @height end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/lite/containers/avl_tree/node.rb', line 7 def key @key end |
#left ⇒ Object
Returns the value of attribute left.
8 9 10 |
# File 'lib/lite/containers/avl_tree/node.rb', line 8 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
8 9 10 |
# File 'lib/lite/containers/avl_tree/node.rb', line 8 def right @right end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/lite/containers/avl_tree/node.rb', line 8 def value @value end |
Class Method Details
.instance(key, value) ⇒ Object
10 11 12 |
# File 'lib/lite/containers/avl_tree/node.rb', line 10 def self.instance(key, value) new key, value end |
Instance Method Details
#inspect ⇒ Object
28 29 30 31 |
# File 'lib/lite/containers/avl_tree/node.rb', line 28 def inspect lr = "#{left.nil? ? 0 : :L}|#{right.nil? ? 0 : :R}" "#<#{self.class.name} @key: #{key}, @value: #{value}, @height: #{height} #{lr}" end |
#out ⇒ Object
24 25 26 |
# File 'lib/lite/containers/avl_tree/node.rb', line 24 def out raise NotImplementedError, "#{self.class.name}##{__method__} unimplemented" end |