Efficient data structures in Android development

Source: Internet
Author: User

Android development, in JAVA2EE or Android common data structure has map,list,set, but Android as a mobile platform, some API (many are efficiency issues) is obviously not ideal, in the spirit of making better wheels, The Android team has written its own API to replace the Java API

    1. Simplearraymap<k,v> and Arraymap<k,v>

Essentially Arraymap inherited from Simplearraymap, mainly in order to implement a HashMap-like API method, so that the habit of using HashMap developers feel no difference, essentially simplearraymap+map re-encapsulation.

In general, these 2 classes are used primarily instead of hashmap because they are more efficient than hashmap and are optimized for memory.

2.sparsearray<t> and Sparsearraycompat<t> and longsparsearray<t>

Of these 3 classes, the first 2 are basically the same class, except that the second class has a RemoveAt method, and the third is a long type.

These 3 classes are also used to replace HashMap, except that their key type is integer integer or long type, in real development, such as month abbreviation mapping, or file cache mapping, Viewholder is particularly suitable for

3.AtomicFile

Atomicfile first is not used instead of file, but as the auxiliary class of file from in, the function of Atomicfile is to implement the transactional atomic operation, that is, the file read and write must be complete, suitable for the file read and write operation in multi-threading.

Secure operation for file read and write in multi-threading

Efficient data structures in Android development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.