wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Best List Implementation To Represent An Organization Tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Best List Implementation To Represent An Organization Tree" Watch "Best List Implementation To Represent An Organization Tree" New topic
Author

Best List Implementation To Represent An Organization Tree

Jason Ferguson
Ranch Hand

Joined: Aug 09, 2007
Posts: 58
I have an organization tree with a single top level. The top level can have any number of children, the children can have any number of children, etc.

The question is: which List implementation is better here? If I know the organization tree will stay relatively small and won't change too often, the ArrayList is a better choice. If I know the tree might be quite large or might change fairly often, would LinkedList be a better choice?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11479
    
  16

why use a list for tree structure at all? Why not some kind of, i dunno, TREE structure?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jason Ferguson
Ranch Hand

Joined: Aug 09, 2007
Posts: 58
I'm using Hibernate (mostly Criteria) queries to retrieve the data. The methods of the Criteria object return List. I'm not going to rip out all of my database access code for one Use Case.

Originally posted by Fred Rosenberger:
why use a list for tree structure at all? Why not some kind of, i dunno, TREE structure?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best List Implementation To Represent An Organization Tree