• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing a TreeModel structure

 
Trevor Price
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say I have a very large tree structure (7000+ nodes) and I need to parse it. What's the fastest way to accomplish this? I've been toying with the code below, but it's just too slow.

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to assume that "fastest" refers to how fast you can get the code written:I'm just guessing at what "parse" means in this context, by the way. I'm guessing it means you want to list out all of the nodes in some order. There are several other enumerations you can choose from if you don't like post order.
 
Trevor Price
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, should have been more clear. By "fast", I mean "optimized", i.e., parsing 7000 nodes is hitting my server hard for about 6 seconds. Ultimately, I'm going to need to be able to manipulate the data in multiple ways. Maybe Enumeration isn't the most optimized code for this.

For example:

-----OR-----
 
Jaap Vermeer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well... Paul Clapham's code is definitely the way to go if you want any sort of maintainability. Then to make it faster, you'll have to profile the code and see what it is doing in thos 6 seconds.
Although 1000 iterations a second does not sound absurd, you might be able to make it faster.

The direction you are going, given your example, sounds bad. The order in which the nodes are processed will (likely) not have a major effect on performance, you still need to go through 7000 nodes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic