break even point --> HashMap & ArrayList

R

robert

i've looked for threads both here and on the JDC, but can't find that
anyone has posted about where it makes sense to use ArrayList, and thus
have to build an Iterator in a for loop to find things; rather than
just making a HashMap and use get().

has such been published?

thanks,
robert
 
M

Matt Humphrey

robert said:
i've looked for threads both here and on the JDC, but can't find that
anyone has posted about where it makes sense to use ArrayList, and thus
have to build an Iterator in a for loop to find things; rather than
just making a HashMap and use get().

has such been published?

It would depend on the kind of object and whether it had a good hashcode.
But really, is it worth obscuring your design to solve a performance problem
that probably doesn't even exist? Have you done profiling and found that
this is the most important bottleneck to fix? If it is and you truly have a
small set that needs fast indexing, consider a perfect hash function.

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 
R

robert

Matt Humphrey said:
It would depend on the kind of object and whether it had a good hashcode.
But really, is it worth obscuring your design to solve a performance problem
that probably doesn't even exist? Have you done profiling and found that
this is the most important bottleneck to fix? If it is and you truly have a
small set that needs fast indexing, consider a perfect hash function.

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/

my instinct would have been to use HashMap, but this is pre-existing code,
and the guy who built is no dummy (and not here any longer), but it seemed
over-engineered to use ArrayList and build the additional machinery.

thanks,
robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top