Java collections framework: Difference between revisions

Content deleted Content added
Map interfaces: Add ConcurrentMap section
Map interfaces: Fix subheading issues.
Line 213:
The direct subclasses of {{java|ConcurrentHashMap}} class include {{java|ConcurrentSkipListMap}}, {{java|EnumMap}}, {{java|HashMap}}, {{java|IdentityHashMap}}, {{java|TreeMap}} and {{java|WeakHashMap}}.
 
=====HashMap=====
<code>HashMap</code> uses a [[hash table]]. The hashes of the keys are used to find the elements in various buckets.
 
======LinkedHashMap======
<code>LinkedHashMap</code> extends <code>HashMap</code>by creating a [[doubly linked list]] between the elements, allowing them to be accessed in the order in which they were inserted into the map. <code>LinkedHashMap</code> contains a <code>protected</code> <code>removeEldestEntry</code> method which is called by the <code>put</code> method whenever a new key is added to the <code>Map</code>.{{sfn|Bloch|2018|loc=Chapter §44 Favor the use of standard functional interfaces|pp=199-202}} The <code>Map</code> removes its eldest entry whenever <code>removeEldestEntry</code> returns true.{{sfn|Bloch|2018|loc=Chapter §44 Favor the use of standard functional interfaces|pp=199-202}} The <code>removeEldestEntry</code> method can be overridden.{{sfn|Bloch|2018|loc=Chapter §44 Favor the use of standard functional interfaces|pp=199-202}}
 
=====TreeMap=====
<code>TreeMap</code>, in contrast to <code>HashMap</code> and <code>LinkedHashMap</code>, uses a red–black tree. The keys are used as the values for the nodes in the tree, and the nodes point to the elements in the <code>Map</code>.<ref>{{cite web|url=http://docs.oracle.com/javase/7/docs/api/java/util/Map.html |title=Map (Java Platform SE 7 ) |publisher=Docs.oracle.com |date=2013-06-06 |access-date=2013-08-16}}</ref>