• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tree API?

 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ranchers,

I was wondering if any one can point me to a package or framework for working with objects that are linked in a tree structure. I know all about TreeSet and TreeMap, but those are data structures that are backed by trees. What I'm looking for are interfaces and utility classes that explicitly expose and utilize the tree-like references among a group of objects. Something along the lines of ...

TreeNode node = ...;
SomeUtilityClass.search(node, "search query");

Is there such a package? Or does everyone end up writing their own little BFS and DFS tree search algorithms?
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you see those little dashes under your "TreeNode"? That means that it was found in the Java API. If you click on it you will see that interface, and it's probably exactly what you want. You can use DefaultMutableTreeNode as the concrete implementing class.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Rob. I took a look at the API for TreeNode and DefaultMutableTreeNode. I see how I could use those classes to build a tree data structure. What I wasn't able to find were any utility classes used to search through a tree of TreeNodes. Anybody know of any global tree search implementations in any of the Java packages or ancillary frameworks?
 
Paul Clapham
Sheriff
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you need a "utility class" when DefaultMutableTreeNode already contains methods named breadthFirstEnumeration and depthFirstEnumeration?
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! I failed to notice those methods. Many thanks for your patience.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic