[gatein-issues] [JBoss JIRA] Updated: (GTNPORTAL-1110) Optimize recursive method in searching node
Trong Tran (JIRA)
jira-events at lists.jboss.org
Tue May 4 07:52:05 EDT 2010
[ https://jira.jboss.org/jira/browse/GTNPORTAL-1110?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Trong Tran updated GTNPORTAL-1110:
----------------------------------
Fix Version/s: 3.1.0-GA
> Optimize recursive method in searching node
> -------------------------------------------
>
> Key: GTNPORTAL-1110
> URL: https://jira.jboss.org/jira/browse/GTNPORTAL-1110
> Project: GateIn Portal
> Issue Type: Task
> Reporter: Minh Hoang TO
> Assignee: Minh Hoang TO
> Priority: Minor
> Fix For: 3.1.0-GA
>
> Original Estimate: 4 hours
> Remaining Estimate: 4 hours
>
> public static PageNode[] searchPageNodesByUri(PageNode node, String uri)
> {
> if (node.getUri().equals(uri))
> return new PageNode[]{null, node};
> if (node.getChildren() == null)
> return null;
> List<PageNode> children = node.getChildren();
> for (PageNode ele : children)
> {
> PageNode[] returnNodes = searchPageNodesByUri(ele, uri);
> if (returnNodes != null)
> {
> if (returnNodes[0] == null)
> returnNodes[0] = node;
> return returnNodes;
> }
> }
> return null;
> }
> I see that this method (in PageNavigationUtils ) has been used quite oftenly, but it's not optimal in term of algorithm. Searching a node under a tree with a given path ( array of String parsed as argument, or created by splitting the node uri ) is faster.
> Consider an example where we need to find the node /a/b/c/x/y/z in the navigation N. Assume that in the navigation N there is also the nodes
> /a/b1/c1/...
> /a/b2/c2/...
> /a/b3/c3/...
> .....
> /a/b/c/x/y/z
> The current naive uri comparing will force us to make the comparision in all nodes in branches /a/b1 , /a/b2,....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the gatein-issues
mailing list