Provides utility methods to merge two {Tree::TreeNode} based trees. @since 0.9.0
Merge two trees that share the same root node and returns a new tree.
The new tree contains the contents of the merge between other_tree and self. Duplicate nodes (coming from other_tree) will NOT be overwritten in self.
@author Darren Oakley (github.com/dazoakley)
@param [Tree::TreeNode] other_tree The other tree to merge with. @return [Tree::TreeNode] the resulting tree following the merge.
@raise [TypeError] This exception is raised if other_tree is not a
{Tree::TreeNode}.
@raise [ArgumentError] This exception is raised if other_tree does not
have the same root node as self.
# File lib/tree/utils/tree_merge_handler.rb, line 61 def merge(other_tree) check_merge_prerequisites(other_tree) new_tree = merge_trees(self.root.dup, other_tree.root) return new_tree end
Merge in another tree (that shares the same root node) into
this tree. Duplicate nodes (coming from other_tree)
will NOT be overwritten in self.
@author Darren Oakley (github.com/dazoakley)
@param [Tree::TreeNode] other_tree The other tree to merge with.
@raise [TypeError] This exception is raised if other_tree is not a
{Tree::TreeNode}.
@raise [ArgumentError] This exception is raised if other_tree does not
have the same root node as self.
# File lib/tree/utils/tree_merge_handler.rb, line 80 def merge!(other_tree) check_merge_prerequisites( other_tree ) merge_trees( self.root, other_tree.root ) end