• 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

Effieient collection implementation for faster search.

 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have to use a collection store a pretty large number of objects . Which is a better collection to use in case I have to constantly perform search operations on the collection? I don't actually need a map so that rules out the ones that are based on hashing functions.

Cheers,
Raj.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

constantly perform search operations on the collection?



Searching based on what? What is the nature of these objects?

I don't actually need a map



How did you come to that conclusion?

Bill
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends which order you need to keep the contents of the Collection in. You need to compare the List Set SortedSet and Map interfaces to see how they store their contents.

Most List contains methods probably run in linear time, hash methods probably constant time unless the load factor is high, and sorted set methods probably in logarithmic time.

Performance is unpredictable; you will have to try it and see what happens; and good luck with it
[ November 30, 2008: Message edited by: Campbell Ritchie ]
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raj Kamal:
I have to use a collection store a pretty large number of objects


How large do you consider large? HashMaps are O(1) its really hard to beat that, but they do have a fairly large constant.

Before we can help, you need to be more specific. And make sure that this is not premature optimization.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic