Well I think I've achieved a neat little class in Flat3Map, but I guess
others should decide that. (Its checked in, but if people don't like it I'll
remove it or rename it or otherwise modify it)

Flat3Map is a Map implementation that is optimised for size 3 and less. It
stores data in ordinary fields and does not create an array, map entry or
other complex object until size 3 is breached.

Once size 4 is reached, a HashMap is created and the Flat3Map behaves as per
a decorated HashMap.

Performance wise -
- Gets at size 3 or less are about 0-10% faster than HashMap.
- Puts at size 3 or less are over 4 times faster than HashMap.
- Performance 5% slower than HashMap once size 3 exceeded once.

The gains on put are probably down to object creation and therefore garbage
collection. The new MapIterator should be used to get the maximum advantage,
as it doesn't create MapEntry objects. The performance test class is also
checked in so you can try it out (you have to play with the comments in the
loop).

I also suspect, but can't think how to prove, that Fast3Map will be easier
for the garbage collector to dispose of as it contains no arrays or complex
types to hunt through for dependencies. Any ideas on how to test this?

Opinions? And should there be a Flat1Map, Flat5Map etc. And what about a
Flat3List??

Stephen




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to