Linkedhashmap and Linkedhashset

Source: Internet
Author: User

LINKEDHASHMAP implements the map interface and is the direct subclass of HashMap , which satisfies some features of the HASHMAP and linked lists. You can consider Linkedhashmap as a hashmap with linked list enhancement.

Linkedhashmap , based on HashMap , joins all in the form of a doubly linked list (doubly-linked list) entry , so that the elements are iterated in the same order as they were inserted. The structure of the Linkedhashmap , the body part is exactly the same as the HashMap , which points to the header head of the doubly linked list (which is a dummy element), and the order of the two-way list is the entry order of insertion. In addition to preserving the iterative sequence, this structure has one benefit: iterative Linkedhashmap does not need to traverse the whole like HashMap table , but only to traverse directly to header the doubly linked list, that is to say The iteration time of the Linkedhashmap is related only to entry the number of digits, but not to table the size.

There are two parameters that can affect the performance of the Linkedhashmap : initial capacity (inital capacity) and load factor (payload factor). The initial capacity specifies the initial table size, and the load factor is used to specify the threshold for automatic expansion. When entry the number exceeds capacity*load_factor , the container will automatically expand and re-hash. For scenes with more inserted elements, setting the initial capacity to large can reduce the number of re-hashes.

The Linkedhashmap is non-synchronous (not synchronized).

Storage Structure :

Linkedhashmap and Linkedhashset

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.