Lack of Generic Tree support

I am wondering how people feel about the lack of the Tree type in Java? I find the Java types pretty weak generally, but at least there are several Set, Map, List implementation to choose from. There is no Tree, or perhaps there are too many. There is the UI tree classes (in swing), the Preference class has a tree like interface, JNDI, etc.

I am wondering if this is a problem for others? We ended up creating our own Tree interface and implementations.

Pat O

[480 byte] By [techneexa] at [2007-10-1 22:18:43]
# 1
Tree is usually not needed: it's just Composite pattern. No need in entity descrybing tree as whole.
RoboTacta at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 2
What would your proposed Tree framework look like?Typically, trees are very specific and have specific algorithms.E.g. AVL tree, red-black tree, etc.Have you looked at the DefaultMutableTreeNode? If so, whatis lacking in your opinion?
rkippena at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 3
> Have you looked at the DefaultMutableTreeNode? If so, what is lacking in your opinion?It's Swing. I've used JVMs on headless Linux boxes which had serious issues with AWT to the extent that we simply did not use any AWT or Swing classes.
YAT_Archivista at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 4
> There is no Tree, What about java.util.TreeMap<K,V>
sabre150a at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 5

> > Have you looked at the DefaultMutableTreeNode? If

> so, what is lacking in your opinion?

>

> It's Swing. I've used JVMs on headless Linux boxes

> which had serious issues with AWT to the extent that

> we simply did not use any AWT or Swing classes.

No, it isn't. I mean, sure, it's in a javax.swing.something package, but it doesn't have any GUI components. I don't think headlessness should affect it in the least.

I'm happy to be proven wrong, but only with malfunctioning code, not with a quick look at the name of the package.

DrClapa at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 6
In the source for DefaultMutableTreeNode, at the top there is a comment:// ISSUE: this class depends on nothing in AWT -- move to java.util?
rkippena at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 7

> I don't think headlessness should affect it in the least.

I did wonder whether to pre-empt this reply. Looks like I made the wrong decision.

"Do not use anything in java.awt or javax.swing" was a company policy rather than a technical requirement. However, it had its roots in a technical requirement "Do not use anything which could classload java.awt.Component". DefaultMutableTreeNode is not caught by the technical requirement, but it is caught by the company policy.

YAT_Archivista at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 8

I felt the reply was necessary because your company policy-makers aren't the only ones to reject DefaultMutableTreeNode "because it's Swing". I have seen that view expressed here before. So if you are not encumbered by policy, then DefaultMutableTreeNode is perfectly usable for tree structures.

DrClapa at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 9
Of course there are tree data structures in Java: TreeSet, TreeMap. Do your homework.
dingjinga at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 10

> Of course there are tree data structures in Java:

> TreeSet, TreeMap. Do your homework.

A generic tree type and tree data-structures are not in the same category. Data-structures require specific nodes depending on the tree type. There would be no sense in using a generic tree node class in an AVL tree for example.

rkippena at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...
# 11
May I add Document as a candidate ?
Franck_Lefevrea at 2007-7-13 8:32:34 > top of Java-index,Other Topics,Algorithms...