• Post Reply Bookmark Topic Watch Topic
  • New Topic

Vector or ArrayList use for dropdown with more than 1000 entries  RSS feed

 
vikram karne
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends

I am having more than 1000 entries of different TimeZone's which i need to display in a dropdown list.
i am not able to decide whether i need to use a Vector or Arraylist for storing these values.
please let me know which one will be best suited to use in case the list entry is more than 1000 characters.
waiting for a positive reply from your side.

Thanks & Regards
Vikeng
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would chose the ArrayList, Vector is part of thw older original collections, and is thread safty, however, ArrayList is part of the current collection frame work, but isint thread safe, so it is "quicker".

I dont remember much about drop downs, I havent used them in awhile, but if you know what the Timezones are in advance, how many there are of them, and they arent going to change, I wonder if an array of Timezones would not be better?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are most likely not going to notice any performance difference at all between Vector and ArrayList.

However, I would use ArrayList simply because Vector is an old, legacy collection class for which there is no good reason to use it anymore at all.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really need to inflict a 1000-entry dropdown list on your users? Surely you can think of a better UI: divide the timezones up by region, for example, and display only those for the current region. Or use an input field with typeahead-suggest? Or a map to click on?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think MVC.
You dont really need to populate the values all the values in a vector and then pass them to the JList (I am presuming its a JList as you mentioned drop down).
You need to tweak the following two methods:


Check out the JList API which cites a concrete example.
 
vikram karne
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your replies

Finally i have set all the values in the ArrayList as all of you suggested.
it works for now but need to see the performance issue in the longer run for such a huge list of values.

Thanks a lot once again

Regards
Vikram K
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vikram karne:
but need to see the performance issue in the longer run for such a huge list of values.
You don't need to worry about the performance of the code so much as the performance of the user. As Ernest has already said, requiring a user to search through 1000 items to find the one item they want is not at all user friendly and will be where any performance bottleneck is to be found. Even if it takes a 1 or 2 seconds to populate the list this will be insignificant compared to the minutes it's likely to take the user to find the correct choice.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Tony Docherty:]You don't need to worry about the performance of the code so much as the performance of the user.

Yes, as you state, the advice of EFH and Jesper Young should be given immediate work by the original poster. This approach may not be easy to find on first attempt to solve this design challenge.

Author vikram karne would likely make better progress if one of the Collections has a getInterval(int beginGettingItems, int endOfInterval) method, and it does.



The Collections are all well suited to use in case, it is in fact a GUI issue we actually have here.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!