Differences between ArrayList, Vactor, and LinkList

Source: Internet
Author: User

ArrayList: the underlying data structure is an array structure. You can think of it as a variable-size array that can only hold objects. Because the array has an index (badge), The ArrayList query speed is faster, while adding and deleting elements is slower. Because every time you delete or add an element, you must move all the data after the added or deleted element. This set is not synchronized by threads.
Linked list: the underlying data structure is linked list structure. The data structure of the linked list is not indexed. The current element is only associated with the previous and later elements, just like a beaded child. The data structure features fast addition and deletion, the query is slow, because the addition and deletion only need to find the current element, and then cut off the association between the current element and the previous and last element, and compare it with the array, the linked list does not need to move most of the data repeatedly, but because there is no index, the data structure of the linked list needs to query data one by one, so the query speed of the sorted list is a little slow.
Vector: the underlying data structure is also an array structure. In addition to thread security issues, the underlying data structure is almost the same as that of ArrayList.

The query speed of the array structure is faster, because the element location can be quickly locked through the index. The insert speed of the linked list structure is fast.

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.