?
Solved

Best choice for a collection list

Posted on 2003-03-05
15
Medium Priority
?
173 Views
Last Modified: 2011-04-14
Hi, I'm actually using a vector to store objects. The problem is that i store between 15 000 and 50 000 objects and the time of storage is way too much. Is there a better type of collection than Vector to store my objects. The collection has to work like a queue and i don t do item search.
Thank you
0
Comment
Question by:corback
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +2
15 Comments
 
LVL 1

Expert Comment

by:shji1
ID: 8071265
Try ArrayList.
--Shaji
0
 
LVL 35

Expert Comment

by:girionis
ID: 8071270
 Even though Vector is part of the Java Collection Framework (and the collection framework is not synchronized) Vector *is* synchronized. So if your application needs not to be thread safe I sugegst you use an ArrayList which, if you need synchronization in the future, you can always synchronize.

 If you want to give even greater flexibility to your application, I suggest you use the List interface:

  List myList = new ArrayList();

  So if your needs change in the future you could also do a

  List myList = new Vector();

  since Vector implements List.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 8071372
A LinkedList will probably be your most lightweight option
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:corback
ID: 8072094
I ve already tried to use an arrayList but the performance are the same. In fact all i need is a list working like a "simple linked list" in C.  
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8072130
Well, i've already suggested that ;-)

(java.util.LinkedList)
0
 

Author Comment

by:corback
ID: 8072175
I ve already tried to use an arrayList but the performance are the same. In fact all i need is a list working like a "simple linked list" in C.  
0
 

Author Comment

by:corback
ID: 8072272
I ve already tried to use an arrayList but the performance are the same. In fact all i need is a list working like a "simple linked list" in C.  
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 8072277
Please review your code, corback, I tried and a LinkedList or an ArrayList is 2ce as fast as a Vector!
;JOOP!
0
 

Author Comment

by:corback
ID: 8072343
oops sorry for the message :), refresh is not a good thing to do :)
I ve tried linkedList and same problem : to add 15 000 elements to a list/arrayList/Vector i need 5 seconds ... but unfortunatly i have to do it in about 2 seconds :(
Thank you all for your help
0
 
LVL 35

Expert Comment

by:girionis
ID: 8072350
 Have you tried a simple array?
0
 
LVL 1

Expert Comment

by:shji1
ID: 8073606
How about writing your own List?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8074669
You're saying what exactly? It's taking you 5 seconds to add 15000 object references to a LinkedList or it's taking you 5 seconds to do this after doing other things as well?
0
 

Author Comment

by:corback
ID: 8078442
i m really sorry in fact the problem didnt come from the insertion into the list ... i m really sorry to have disturbed you
Have a nice day
0
 

Author Comment

by:corback
ID: 8078445
Thank you for your support :)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8079050
>>i m really sorry in fact the problem didnt come from the insertion into the list

That's ok. I'd take a guess that somebody's told you 'Java is slow' in the past ;-)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question