List Map Set Summary

Source: Internet
Author: User

Whether the parentheses are thread safe

List:linkedlist (NO) ArrayList (NO) Vector (yes) Stack (yes)

Map:hashmap (NO) linkedhashmap (NO) HashTable (yes) Weakhashmap TreeMap

Set:hashset (NO) linkedhashset (NO) SortedSet TreeSet

Most commonly used as if the first two of each row

Characteristics:

1. Linked opening for quick insertion, deleting elements, linked maintaining the order in which elements are inserted

2. Set is implemented on a HashMap basis, so the key at the end of the set is not duplicated

3. The tree begins with a sequence of changes occurring at a slower speed

Apply:

1. Need to quickly insert, delete elements, with LinkedList; Requires fast random access to elements, with ArrayList

2. Vectors are similar to ArrayList, but are synchronous

3. Stack inherits vectors, is the last-in-first-out stacks

4. HashMap, the position of the put in the object will change, Linkedhashmap will not

5. HashSet is specifically designed for quick queries, insert will produce a sort (linkedhashset not), the object deposited HashSet must define Hashcode method

6. SortedSet is a set interface that maintains an ordered sequence of elements, and the elements added to the SortedSet implementation class must implement the comparable interface, and the TreeSet class is its only implementation

Other:

1. unsynchronized can be externally synchronized, or use Collections.synchronizedmap () method to wrap it into a thread-safe map/set

2. Linkedhashmap supports two kinds of sorting: Insert order, Access order. The former refers to the order in which they are inserted, which refers to the order in which the oldest use is used to the most recent

List Map Set Summary

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.