Re: Is There a Java Class for this Kind of Data Structure?
"Hal Vaughan" <hal@thresholddigital.com> wrote in message
news:qOudnRD3JNZLPAvbnZ2dnUVZ_uuqnZ2d@comcast.com...
I did have a method I could call in one table that would step through
all
the dependent tables and update them and the Swing components that used
them for setting data, the problem was it was easiest to go through the
list of all dependent tables and for each one call the update, which
would
go to that table and do the same. In essence the update would start at
the
trunk and follow one branch, then take one fork and so on through to the
end of one branch, then it would back up and go through the next branch.
That worked, or mostly worked, but I found the problem was that tables
several levels down would be updated before some tables only 1 level
down
were updated and that would effect what was displayed on the Swing
components. The reason I want to store the tables in a tree is so I can
get more easily make sure I update all tables 1 level down then move to
2
levels down and so on. That way I update all the tables in each level
before moving on to the next level.
If "ordering" is an issue, see
http://en.wikipedia.org/wiki/Tree_traversal
Note that the problem may also be that your data objects are correctly
being updated, but your GUI is not being updated to reflect the new values
stored in memory.
From what I can see, there is no way to get all the objects from a tree
at
one level. I was considering using the DefaultTreeModel, but that one
issue kept me back. At this point, because I want to go level by level,
I'm thinking of using one list and each item is a list of all the tables
at
that level.
You can do that, but this particular configuration of having a list of
list of elements at a given level doesn't sound like it would be conducive
to writing a recursive algorithm. The usual way to go about it is to take
care of a single node, and then to take care of all of its children. So
rather than working with lists, you'd be working with trees. See
http://en.wikipedia.org/wiki/Recursion
- Oliver