Domanda

In my Android application I have used Hash maps in many situations. And I was asked to use sparse arrays by concerning the performance of the application. So, how sparse array differs from a hashmap in java and what are the advantages of sparse array over hashmap . Thank You.

È stato utile?

Soluzione

I beleive the description of sparse array clearly mentions the difference:

It is intended to be more memory efficient than using a HashMap to map Integers to Objects, both because it avoids auto-boxing keys and its data structure doesn't rely on an extra entry object for each mapping.

For further reading: http://developer.android.com/reference/android/util/SparseArray.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top