New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerators for TreeNode#postordered_each and TreeNode#breadth_each faulty #31

Closed
MMF2 opened this Issue Oct 19, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@MMF2

MMF2 commented Oct 19, 2014

If TreeNode#postordered_each or TreeNode#breadth_each are called without a block to get the enumerators, these enumerators incorrectly enumerate in the same order as TreeNode#preordered_each. If called instead with blocks they enumerate correctly.
Example:
t = Tree::TreeNode.new('1')
t << Tree::TreeNode.new('2') << Tree::TreeNode.new('4')
t << Tree::TreeNode.new('3') << Tree::TreeNode.new('5')
t['3'] << Tree::TreeNode.new('6')
a = []
t.postordered_each {|n| a << n.name}
a # => ["4", "2", "5", "6", "3", "1"](correct postorder)
t.postordered_each.collect {|n| n.name} # => ["1", "2", "4", "3", "5", "6"](that's preorder instead of
postorder)

@evolve75 evolve75 added the Bug label Oct 25, 2014

@evolve75 evolve75 added this to the 0.9.5 milestone Oct 25, 2014

@evolve75 evolve75 self-assigned this Oct 25, 2014

@evolve75

This comment has been minimized.

Show comment
Hide comment
@evolve75

evolve75 Oct 25, 2014

Owner

This bug is due to the code-line:

     return self.to_enum unless block_given? 

in both postordered_each and breadth_each methods.

Owner

evolve75 commented Oct 25, 2014

This bug is due to the code-line:

     return self.to_enum unless block_given? 

in both postordered_each and breadth_each methods.

@evolve75

This comment has been minimized.

Show comment
Hide comment
@evolve75

evolve75 Oct 25, 2014

Owner

Fixed. Will be in 0.9.5pre.

Owner

evolve75 commented Oct 25, 2014

Fixed. Will be in 0.9.5pre.

@evolve75 evolve75 closed this Oct 25, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment