Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Breaking a JTree Traversal

 
Casen Densmore
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running a traversal of a JTree trying to find a certain node. When I do find that node I want to return true, indicating that I did in fact find it. The code below always returns false indicating to me that even though I return true when the item is found the loop continues to run.



Here is the print out of the test code.
Match Found!
No Match Found 1
No Match Found 1
false <------- a printout from what is returned.

Any ideas?
Thanks,
Casen
 
Casen Densmore
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I see why it isn't working. I am calling multiple instance of the method therefore it would return a value for each one of them; the last one being false.

The question still remains, how can I manipulate the code so that once a match is found it would return true and stop the recursion?

Thanks,
Casen
 
Brian Cole
Author
Ranch Hand
Posts: 886
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are ignoring the return value of the recursive call to traverse().
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic