388 |
|
// Comparison and hashing |
389 |
|
|
390 |
|
/** |
391 |
< |
* {@inheritDoc} |
391 |
> |
* Compares the specified object with this map for equality. Returns |
392 |
> |
* <tt>true</tt> if the given object is also a map and the two maps |
393 |
> |
* represent the same mappings. More formally, two maps <tt>m1</tt> and |
394 |
> |
* <tt>m2</tt> represent the same mappings if |
395 |
> |
* <tt>m1.entrySet().equals(m2.entrySet())</tt>. This ensures that the |
396 |
> |
* <tt>equals</tt> method works properly across different implementations |
397 |
> |
* of the <tt>Map</tt> interface. |
398 |
|
* |
399 |
|
* <p>This implementation first checks if the specified object is this map; |
400 |
|
* if so it returns <tt>true</tt>. Then, it checks if the specified |
404 |
|
* contains each mapping that this map contains. If the specified map |
405 |
|
* fails to contain such a mapping, <tt>false</tt> is returned. If the |
406 |
|
* iteration completes, <tt>true</tt> is returned. |
407 |
+ |
* |
408 |
+ |
* @param o object to be compared for equality with this map |
409 |
+ |
* @return <tt>true</tt> if the specified object is equal to this map |
410 |
|
*/ |
411 |
|
public boolean equals(Object o) { |
412 |
|
if (o == this) |
442 |
|
} |
443 |
|
|
444 |
|
/** |
445 |
< |
* {@inheritDoc} |
445 |
> |
* Returns the hash code value for this map. The hash code of a map is |
446 |
> |
* defined to be the sum of the hash codes of each entry in the map's |
447 |
> |
* <tt>entrySet()</tt> view. This ensures that <tt>m1.equals(m2)</tt> |
448 |
> |
* implies that <tt>m1.hashCode()==m2.hashCode()</tt> for any two maps |
449 |
> |
* <tt>m1</tt> and <tt>m2</tt>, as required by the general contract of |
450 |
> |
* {@link Object#hashCode}. |
451 |
|
* |
452 |
|
* <p>This implementation iterates over <tt>entrySet()</tt>, calling |
453 |
< |
* <tt>hashCode()</tt> on each element (entry) in the set, and |
454 |
< |
* adding up the results. |
453 |
> |
* {@link Map.Entry#hashCode hashCode()} on each element (entry) in the |
454 |
> |
* set, and adding up the results. |
455 |
|
* |
456 |
+ |
* @return the hash code value for this map |
457 |
|
* @see Map.Entry#hashCode() |
443 |
– |
* @see Object#hashCode() |
458 |
|
* @see Object#equals(Object) |
459 |
|
* @see Set#equals(Object) |
460 |
|
*/ |