On Jul 16, 2007, at 22:25, J.Pietschmann wrote:

Vincent Hennebert wrote:
Addition of a general-purpose int-to-int map ...
This change makes me a bit uneasy. No doubt that this class is clever
and efficient and working, but that's something more to maintain.

Jakarta Commons Collections has all kind of clever implementation.
Don't they have already something similar, and if not, would it make
sense to donate this implementation to Collections?

Not sure if it would fit in there. It seems more meant for classes extending the Java Collections Framework. I precisely abandoned any attempt to make it fit into the JCF. Started out by implementing java.util.Map, but soon experienced that as adding additional annoyances than relieving any.

As to the efficiency:
I did some measurements of the difference in processing speed (for 64K elements), and the factor lies somewhere between 5 and 20 (times faster). A difference that is not caused by the HashMap lookups, but almost solely due to the necessary Integer constructions and casts...

So, the motives were more aesthetic, I guess. More caused by my aversion for the dumb Integer immutables... I have nothing against HashMaps, but I just do not care much for lines of code like this:

int someInt = ((Integer) someMap.get(new Integer (anotherInt))).intValue();

Granted, CPUs have become so fast and JVMs have been optimized in such a way that one does not even notice the difference unless when executing this ugly line of code 10 million times in a row, but still...



Reply via email to