commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy McArthur" <sandy...@gmail.com>
Subject Re: [primitives] objects indexed by int's and long's
Date Sun, 19 Feb 2006 06:09:44 GMT
On 2/18/06, robert burrell donkin <robertburrelldonkin@blueyonder.co.uk> wrote:
> an IntMap (for want of a better name) would have
>
> Object get(int key)
>
> rather than
>
> Object get(Object key)
>
> and so would avoid creating these intermediary key objects.

Looks like to me what you really want is a SparseArrayList implementation.

With a Map the int from key.hashCode() is a hint to optimize finding
of the actually key. If you already have an int and that is the key,
there is almost nothing to optimize. With an ArrayList you just jump
to the value, no need to seach for it, couldn't be faster.
Unfortunatly that may waste large chunks of memory in the space
between meaningful indexes.

Now that I think of it more, I think you want a SkipList or something
similar. http://en.wikipedia.org/wiki/Skip_list (I'm kind of suprised
I don't see a SkipList in Commons Collections.)

--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message