Re: Java Tree Implementations
David Jordan <[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <[email protected]> |
I have developed many applications over the years that have involved tree structures, they are definitely vital in many applications. But the nodes in the trees I have developed have always been specific classes in my application domain, a given tree often has nodes of many different classes. A general tree data structure would have a generic tree node class representing all the nodes in the tree. With such a representation, your object model would lose track of the abstractions you are trying to model and the type safety of the type of node that can be placed at a certain location in the tree structure. It sounds like you want to have standard tree algorithms like depth-first and breadth first algorithms implemented for you. I suppose some Java interfaces could be defined that yielded tree traversal functionality could be implemented, the classes in your tree would need to implement those interfaces. Algorithms could be defined that walk the tree through these generic interfaces, when in reality they are reference objects whose types are specific to your application. With this approach, you would get the benefits of both approaches (generic versus domain-specific). David Jordan On Mar 25, 2009, at 5:27 PM, Craig Taylor wrote: > Why is there no common tree interface / api within the java.util or > apache collections framework? I see items such as TreeMap and > TreeBag but they don't appear to implement any tree operations - > merely they provide details on how their underlying implementation > is implemented. I'm in need of a tree library that I could define my > own grouping & equality comparator's, in addition to needing the > basic traversal over nodes, getting all sub-nodes etc. > > I would think trees are used often enough to warrent inclusion in > one of the base libraries. > > -- > ------------------------------------------- > Craig Taylor > > > _______________________________________________ > Juglist mailing list > [email protected] > http://trijug.org/mailman/listinfo/juglist_trijug.org