[antlr-interest] Re: ANTLR 3 tree structure stuff

Terence Parr parrt at cs.usfca.edu
Wed Nov 10 11:01:03 PST 2004



On Nov 10, 2004, at 7:12 AM, atripp54321 wrote:
> Why not use the built-in Swing TreeNode data structure?
> TreeNode is the interface:
> http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/tree/TreeNode.html
> and DefaultMutableTreeNode is your typical implementation:
> http://java.sun.com/j2se/1.5.0/docs/api/javax/swin
> g/tree/DefaultMutableTreeNode.html

Hi Andy,

Thanks for the pointers...well, I don't like Java's libraries much ;) 
except for collections so my structure would be just a thing with a 
List of children and a parent pointer.

> DefaultMutableTreeNode (ugg, what an awful name!) may seem like
> overkill, but hey, if the code's already there and working, why not?

Because "there and working" means something different when you're 
talking about sun. ;)  I cite their I/O library and net library.  
Anybody care to guess what happens when you miss on the DNS lookup?  
Yes, it keeps the lock on the cache and does a net transaction; making 
all other threads wait.  Blah blah blah, you get the point. ;)  
Lectures on how to make java go fast are all about how to avoid using 
sun's libraries ;)

> The only difference I see between your proposal and this is
> that you have stuff like getNextSibling(), while the built-in
> one forces you to use an iterator (actually, it's still using
> Enumeration rather than Iterator - another uggh!).

;)  Yeah, I'm beginning to thing I don't need that next sibling stuff.  
I thought about tree parsing last night.

> See also the tutorial:
> http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
> Note that creating a visual JTree becomes trivial, just pass it
> the root DefaultMutableTreeNode:
> JTree tree = new JTree(root);

A good selling point.

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list