Class: DcUtil::BinaryNode
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#left ⇒ Object
returns left child.
-
#left=(node) ⇒ Object
set left child.
-
#right ⇒ Object
returns right child.
-
#right=(node) ⇒ Object
set right child.
Methods inherited from Node
#add, bfs, #bfs, bfs_non_recursive, dfs, #dfs, #initialize, #leaves, #parents, #tree_size
Constructor Details
This class inherits a constructor from DcUtil::Node
Instance Method Details
#left ⇒ Object
returns left child
4 5 6 |
# File 'lib/dc_util/binary_node.rb', line 4 def left children[0] end |
#left=(node) ⇒ Object
set left child
14 15 16 17 18 |
# File 'lib/dc_util/binary_node.rb', line 14 def left=(node) raise ArgumentError.new("not a valid node class") unless node.kind_of? self.class children[0] = node node.parent = self end |
#right ⇒ Object
returns right child
9 10 11 |
# File 'lib/dc_util/binary_node.rb', line 9 def right children[1] end |
#right=(node) ⇒ Object
set right child
21 22 23 24 25 |
# File 'lib/dc_util/binary_node.rb', line 21 def right=(node) raise ArgumentError.new("not a valid node class") unless node.kind_of? self.class children[1] = node node.parent = self end |