I generally use vectors/arraylists , hashmaps/treemaps, and other java collections interchangeably, with exception of the fact that there are sometimes functional API requirements (for example, I might need a sorted data set in certain instances).
Lately, however, I've found a need to push java performance to the limit for some algorithms I'm running.
Is there a set of guidelines for high-performance data structures, that I can use as ground rules for my coding ?
I'm looking for general rules, but, in this context, answers to the following questions might also be very helpful :
1) When should I use multidimensional arrays instead of nested Collections ?
2) Vectors vs. ArrayLists - is there truly a performance difference ?
3) Do collection API's like Google's collections, java tricks (like reflection and casting), and other common java developer idioms tend to slow down the JVM when it is under heavy load ?
4) Do primitives vs regular objects (i.e. Double vs double) slow down the JVM when doing lots of calculations ?
5) Are there other important guidelines for dealing with large collections in java programs which need to be high-performance ?
- Note : at this point, I'm not doing any multithreading... I realize that there are other constraints which might apply once I start parallelizing .