LinkedHashMap

  • If you want near-HashMap performance and insertion-order iteration, use LinkedHashMap.
  • LinkedHashMap provides two capabilities that are not available with LinkedHashSet. When you create a LinkedHashMap, you can order it based on key access rather than insertion. In other words, merely looking up the value associated with a key brings that key to the end of the map.
  • LinkedHashMap provides the removeEldestEntry method, which may be overridden to impose a policy for removing stale mappings automatically when new mappings are added to the map. This makes it very easy to implement a custom cache.

LinkedHashMap — Structure map

Clickable & Draggable!

LinkedHashMap — Related pages: