• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Displaying a Huge Vector Quickly

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to optimize the display time for a large (8000+ element) Vector.
Each element of the Vector contains an Array of Strings returned from a search on a XML document.
I am currently displaying the contents in a (JTextArea text), by iterating through the Vector start to finish and calling text.append("").
This process takes significantly longer than a SAX parser iterating through a 1 million line XML file.
Would it be quicker if I used a Hashtable and if so can they be dumped into any swing component? Is there any other way to quickly display a Vector in swing.
Thanks in Advance.
Aran
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How about appending everything to a StringBuffer and then calling setText on the JTextArea just once?
HTH,
Abhik.
 
Arann King
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi thanks for the reponse,
I tryed using a StringBuffer and it is significantly faster however on repeated attempt I get a java.lang.OutOfMemoryError
I tried setting the Buffer to null after each search but to no avail.
Here is the extract
StringBuffer x = new StringBuffer();
for ( j = 0; j < tokens.length; j++) {
//casting object into a string array
a = (String[]) tokens[j];
//int t = j-1;
x.append("\n Result Number "+(j+1)+"\n");
for (int i = 0; i < a.length; i++) {
print = (String) a[i] + '\n';
x.append(print);
//print =print +'\n'+ aa;
}
x.append("\n");
//print =print +'\n';
}
//text.(print);
x.append("\n Number of Results = "+j);
text.setText(x.toString());
time();
x = null;
Any help appreciated.
Thanks
Aran
 
Arthur, where are your pants? Check under this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic