Java collections framework: Difference between revisions

Content deleted Content added
Corrected spelling.
Add details for ConcurrentHashMap
Line 218:
 
=====HashMap=====
<code>HashMap</code> uses a [[hash table]]. The hashes of the keys are used to find the elements in various buckets. The <code>HashMap</code> is a hash-based collection. {{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}}
 
======LinkedHashMap======
Line 225:
=====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>
 
=====ConcurrentHashMap=====
{{java|ConcurrentHashMap}} is similar to <code>HashMap</code> and is also a hash-based collection. {{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}} However, there are a number of differences, such as the differences in the locking strategy they use.
 
The {{java|ConcurrentHashMap}} uses a completely different locking strategy to provide improved scalability and concurrency.{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}} {{java|ConcurrentHashMap}} does not synchronize every method using the same lock.{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}} Instead, {{java|ConcurrentHashMap}} use a mechanism known as ''lock striping''.{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}} This mechanism provides a finer-grained locking mechanism.{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}} It also permits a higher degree of shared access.{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.2.1 ConcurrentHashMap|pp=85-86}}
 
====SortedMap interface====