module Tree::Utils::TreeMergeHandler
Handles merging of two trees.
Public Instance Methods
Source
# File lib/tree/utils/tree_merge_handler.rb, line 64 def merge(other_tree) check_merge_prerequisites(other_tree) merge_trees(root.dup, other_tree.root) end
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.
Source
# File lib/tree/utils/tree_merge_handler.rb, line 82 def merge!(other_tree) check_merge_prerequisites(other_tree) merge_trees(root, other_tree.root) 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.