Class: RedBlackTree::LeafNode

Inherits:
Node
  • Object
show all
Defined in:
lib/red_black_tree/node/leaf_node.rb

Constant Summary

Constants included from Node::Implementation

Node::Implementation::BLACK, Node::Implementation::COLOURS, Node::Implementation::DIRECTIONS, Node::Implementation::LEFT, Node::Implementation::RED, Node::Implementation::RIGHT

Instance Attribute Summary

Attributes inherited from Node

#data, #tree

Attributes included from Node::Implementation

#colour, #data, #left, #parent, #right, #tree

Instance Method Summary collapse

Methods inherited from Node

inherited

Methods included from Node::Implementation

#black!, #black?, #children, #children_are_leaves?, #children_are_valid?, #close_nephew, #distant_nephew, #leaf?, #opposite_position, #position, #red!, #red?, #sibling, #single_child_is_leaf?, #swap_colour_with!, #swap_position_with!, #valid?, #validate!, #validate_free!

Methods included from Node::LeftRightElementReferencers

#[], #[]=

Methods included from DataDelegation

#method_missing, #respond_to_missing?

Constructor Details

#initializeLeafNode

Returns a new instance of LeafNode.



7
8
9
10
11
# File 'lib/red_black_tree/node/leaf_node.rb', line 7

def initialize
  super nil

  @colour = BLACK
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RedBlackTree::DataDelegation

Instance Method Details

#<=>(other) ⇒ Object



13
14
15
# File 'lib/red_black_tree/node/leaf_node.rb', line 13

def <=> other
  (other.instance_of? LeafNode) ? 0 : -1
end