You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/07/14 13:34:05 UTC

[jira] [Comment Edited] (GROOVY-7487) In groovy.util.Node please Provide please add breathFirstGroupedByLevel

    [ https://issues.apache.org/jira/browse/GROOVY-7487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14626220#comment-14626220 ] 

Paul King edited comment on GROOVY-7487 at 7/14/15 11:33 AM:
-------------------------------------------------------------

Since fixing GROOVY-7488, this functionality is readily achieved (as per the unit test for that feature):
{code}
def root = createTreeFromXmlParser()
def result = [:].withDefault { [] }
root.depthFirst { node, index -> result[index] << node.name() }
assert result == [1: ['root'], 2: ['parent1', 'parent2'], 4: ['grandchild2'],
                  3: ['child1a', 'child1b', 'child2a', 'child2b', 'child2c']]
{code}
So, I am closing this issue. A similar example can be created for breadthFirst.


was (Author: paulk):
Since fixing GROOVY-7488, this functionality is readily achieved (as per the unit test for that feature):
{code}
def root = createTreeFromXmlParser()
def result = [:].withDefault { [] }
root.depthFirst { node, index -> result[index] << node.name() }
assert result == [1: ['root'], 2: ['parent1', 'parent2'], 4: ['grandchild2'],
                  3: ['child1a', 'child1b', 'child2a', 'child2b', 'child2c']]
{code}
So, I am closing this issue.

> In groovy.util.Node please Provide please add breathFirstGroupedByLevel
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-7487
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7487
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-jdk
>            Reporter: Suminda Dharmasena
>            Assignee: Paul King
>            Priority: Minor
>              Labels: usertask
>
> Please add a way to groupBy the level in breath 1st traversal



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)