If you mean you map 'String's to 'int's, then yes, you have some
overhead because of the autoboxing of Java, making 'int's into
'Integer's.

If your map's keys (in this case Strings) can be any possible String,
i would just use a Map<String, Integer>.

Depending on how you use this map, you should create a TreeMap or a
HashMap. TreeMap is more expensive in modifying itself, but fast in
reading. HashMap is more expensive in reading, but faster in modifying
itself.

I don't know what your requirements are, but, in general, i would not
advice you to write your own Map implementation.


On Apr 10, 10:16 am, al capwn <alcapw...@googlemail.com> wrote:
> Currently, I'm using a hashmap which maps strings to integers. I've read
> that using a wrapper for a primitive type in a hashmap has extra cost and
> was wandering if there is an alternative I could use.
>
> I've seen sparsearrays in the sdk, but they map ints to objects but I need
> the opposite. Is there an alternative to hashmap available for this or
> should I write my own class to use an array of strings and a seperate array
> of ints? If I do write my own class, is there a better implementation I
> could do?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to