Comparison of List,linklist,arraylist,map and other related storage data structures

Source: Internet
Author: User
Tags comparison data structures memory usage

List is an interface, ArrayList and LinkedList are two implementation classes, they implement the same way, in fact LinkedList is the real chain list (if not clear what is linked list, need to understand the knowledge of related data structure, this is not one or two words can be said clearly), And ArrayList is implemented by an array, which is not a real linked list, it sets an initial capacity of an array at initialization time, and when there is not enough space, it will reconstruct a larger array and then copy the previous elements.
The fundamental difference between ArrayList and LinkedList is the difference between the two data structures: arrays and lists. Refer to the relevant data structure for more information.
Here's a brief summary of what I'm doing here:
ArrayList: Cons: Memory usage is larger, adding delete elements is less efficient. Element random access is highly efficient.
LinkedList: On the contrary.

List,map is an interface
ArrayList is a form of implementation of the list, it is non-thread-safe, while the inside of the things are in the order of addition, and will not automatically give you the sort, you add: 3,5,4 He will not give you a line 345. It is arranged only in the order in which it is added.
HashMap is a form of implementation of map, it is also non-thread-safe, it is unordered, you can add something after the calculation of the hash value in front of the back, he mainly by the form of key and value to obtain

The elements in the list are repeatable
The elements in set are non-repeatable

List is suitable for frequently appending data, inserting, deleting data. But the efficiency of random fetch is low.
The set is suitable for regular random storage, insertion, and deletion. But the efficiency is lower in the times.

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.