commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tatu Vanhanen" <>
Subject RE: [primitives] Looking for a primitive hashtable
Date Wed, 31 Mar 2004 07:17:36 GMT
I'm not the original sender, but interesting issue though.

> From: Rodney Waldhoff []
> Since the existing commons-primitives component was punted out of
> commons-collections, commons-primitives is probably the place for it here.
> Depending upon your density, isn't Object[] essentially an int-keyed map?

Yes but no ;) Using an integer (or long, short, etc) as an index is quite
different than using it as a hash key. As an example concider a situation
where you would like to cache some objects to a map based on the object's id
(an integer). If there are a lot of objects, it feels bad to allocate a lot
of Integers to be able to use the id as a key. And it also feels bad to just
allocate an Object array big enough to handle the biggest possible id and
somehow manage the array as values are inserted, removed and updated. So:
map functionality is needed.

It is true that a primitive-keyed-map probably uses an Object array to store
the values. But to be useful as a general purpose map, an Object array needs
some functionality around it. And the result is... an int-keyed map.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message