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