Am 28.03.2013 16:28, schrieb Martin Nowak:

On 03/20/2013 02:44 PM, Sönke Ludwig wrote:

Built-in AAs use a linked list to handle collisions and thus allocate
for every element that is inserted. HashMap on the other hand uses a
single closed array to store all elements and uses a special key value
(e.g. null) to mark an empty slot. This makes it a lot more memory
and cache friendly, although deletions and handling many big-objects
can have a higher overhead.

We should collect more statistical data or benchmarks to optimize the
standard implementation. I do agree, that arrays make a saner default
choice, but only for a reasonable load factor.

Definitely. The main reason here is just to avoid any GC/heap
allocations as long as the number of timer object stays constant. In
other places I use it to keep down the per-item overhead when large
numbers of small objects are stored and then looked up many times -
performing many insertions/deletions during use will usually have a bad
impact on performance due to the way conflicts are resolved and because
of the array reallocations. The fact that it needs a special key value
to mean "empty" also really makes it unsuitable as a standard AA
implementation.