Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hashmap vs Bundle in Android Efficiency and Performance Comparison

I am trying to understand the performance impact of using a HashMap vs a Bundle in an Android program. I understand that a Bundle is a specialized Android component - does it therefore make it superior to a HashMap if one needed to simply store basic data types (Integers, Strings etc.) and not complex objects?

like image 950
Rick Avatar asked Nov 04 '22 18:11

Rick


1 Answers

Bundles are actually built on top of ArrayMaps, which are memory-efficient implementations of Maps. For smaller ArrayMaps, a search takes less computational time than computing the hash for a similarly populated HashMap. But if you have more than a few hundred items in it, the HashMap will perform better.

Besides, Bundles were not designed to be general-purpose data structures.

like image 180
erich Avatar answered Nov 14 '22 21:11

erich