• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Parsing a TreeModel structure

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 28295
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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-----
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic