I need a map from int to certain objects. I wanted to use the HashMap, but in the documentation of SparseArray it says that SparseArray is intented to be *more efficient*: http://developer.android.com/reference/android/util/SparseArray.html
However i think the documentation is not entirely correct and needs more info: When reviewing the sourcecode of SparseArray and comparing it with the HashMap i come to the following conclusion Source code of Sparse Array: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/util/SparseArray.java;hb=HEAD For SpareArray: Time complexity for reads and writes on a map of size N is log2(N) + 1, However the time complexity for a HashMap of size N is C*N (where C is a constant) (according to the javadoc http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html) So maybe SparseArray is more efficient with respect to space complexity it is not for time complexity. So for programs that need high performance a HashMap may be better. At least thats what i think. Am i right? Am i wrong? I need a very fast implementation for my game :-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---