• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Tree API?

 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh! I failed to notice those methods. Many thanks for your patience.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic