As the docs say, This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries.
. This has the benefit of allowing predictable iteration order, but the disadvantages are increased memory usage and probably higher insertion cost - nothing comes for free, the additional structure (linked list) uses some memory and requires extra CPU cost in order to be maintained.
Disadvantages of a LinkedHashMap?
-
19-06-2023 - |
Lösung
Andere Tipps
Yes there is. LinkedHashMap
differs from HashMap
in that the order of elements is maintained.
So in order to maintain order, LinkedHashMap
needs the expense of maintaining a linked list. Whereas a HashMap
has no such overhead leading to a better performance than a LinkedHashMap
.
Note that LinkedHashMap
implements a normal hashtable, but with the added benefit of the keys of the hashtable being stored as a doubly-linked list.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow