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

Vector or ArrayList use for dropdown with more than 1000 entries

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic