commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karthik Kumar" <karthikku...@gmail.com>
Subject Re: [primitives] objects indexed by int's and long's
Date Sun, 19 Feb 2006 12:16:45 GMT
As was said:

Object get(Object o) can be simply turned into a special case of: get(
o.hashCode()); Which simply maps an object onto itself. For non-mutable
objects, hashCodes may be precalculated and stored. This will lead to a
reduction in lookup times for a given object as well.

A SparseArrayList is a great idea if the keys are clustered. However, is
they are not, it would require O(lg(key)) to search for the objects. If that
is not what you want, it would be better to make buckets based on mapping
the integer to a very manageable size (like 31 or so).

--
Karthik
http://guilt.bafsoft.net
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message