ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/AbstractMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/AbstractMap.java (file contents):
Revision 1.17 by jsr166, Sat Sep 10 20:15:50 2005 UTC vs.
Revision 1.22 by jsr166, Sun Jun 25 19:09:31 2006 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9   import java.util.Map.Entry;
10  
11   /**
# Line 30 | Line 29 | import java.util.Map.Entry;
29   * constructor, as per the recommendation in the <tt>Map</tt> interface
30   * specification.
31   *
32 < * <p>The documentation for each non-abstract methods in this class describes its
32 > * <p>The documentation for each non-abstract method in this class describes its
33   * implementation in detail.  Each of these methods may be overridden if the
34   * map being implemented admits a more efficient implementation.
35   *
36   * <p>This class is a member of the
37 < * <a href="{@docRoot}/../guide/collections/index.html">
37 > * <a href="{@docRoot}/../technotes/guides/collections/index.html">
38   * Java Collections Framework</a>.
39   *
40   * @param <K> the type of keys maintained by this map
# Line 596 | Line 595 | public abstract class AbstractMap<K,V> i
595              return oldValue;
596          }
597  
598 +        /**
599 +         * Compares the specified object with this entry for equality.
600 +         * Returns {@code true} if the given object is also a map entry and
601 +         * the two entries represent the same mapping.  More formally, two
602 +         * entries {@code e1} and {@code e2} represent the same mapping
603 +         * if<pre>
604 +         *   (e1.getKey()==null ?
605 +         *    e2.getKey()==null :
606 +         *    e1.getKey().equals(e2.getKey()))
607 +         *   &amp;&amp;
608 +         *   (e1.getValue()==null ?
609 +         *    e2.getValue()==null :
610 +         *    e1.getValue().equals(e2.getValue()))</pre>
611 +         * This ensures that the {@code equals} method works properly across
612 +         * different implementations of the {@code Map.Entry} interface.
613 +         *
614 +         * @param o object to be compared for equality with this map entry
615 +         * @return {@code true} if the specified object is equal to this map
616 +         *         entry
617 +         * @see    #hashCode
618 +         */
619          public boolean equals(Object o) {
620              if (!(o instanceof Map.Entry))
621                  return false;
# Line 603 | Line 623 | public abstract class AbstractMap<K,V> i
623              return eq(key, e.getKey()) && eq(value, e.getValue());
624          }
625  
626 +        /**
627 +         * Returns the hash code value for this map entry.  The hash code
628 +         * of a map entry {@code e} is defined to be: <pre>
629 +         *   (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
630 +         *   (e.getValue()==null ? 0 : e.getValue().hashCode())</pre>
631 +         * This ensures that {@code e1.equals(e2)} implies that
632 +         * {@code e1.hashCode()==e2.hashCode()} for any two Entries
633 +         * {@code e1} and {@code e2}, as required by the general
634 +         * contract of {@link Object#hashCode}.
635 +         *
636 +         * @return the hash code value for this map entry
637 +         * @see    #equals
638 +         */
639          public int hashCode() {
640              return (key   == null ? 0 :   key.hashCode()) ^
641                     (value == null ? 0 : value.hashCode());
# Line 693 | Line 726 | public abstract class AbstractMap<K,V> i
726              throw new UnsupportedOperationException();
727          }
728  
729 +        /**
730 +         * Compares the specified object with this entry for equality.
731 +         * Returns {@code true} if the given object is also a map entry and
732 +         * the two entries represent the same mapping.  More formally, two
733 +         * entries {@code e1} and {@code e2} represent the same mapping
734 +         * if<pre>
735 +         *   (e1.getKey()==null ?
736 +         *    e2.getKey()==null :
737 +         *    e1.getKey().equals(e2.getKey()))
738 +         *   &amp;&amp;
739 +         *   (e1.getValue()==null ?
740 +         *    e2.getValue()==null :
741 +         *    e1.getValue().equals(e2.getValue()))</pre>
742 +         * This ensures that the {@code equals} method works properly across
743 +         * different implementations of the {@code Map.Entry} interface.
744 +         *
745 +         * @param o object to be compared for equality with this map entry
746 +         * @return {@code true} if the specified object is equal to this map
747 +         *         entry
748 +         * @see    #hashCode
749 +         */
750          public boolean equals(Object o) {
751              if (!(o instanceof Map.Entry))
752                  return false;
# Line 700 | Line 754 | public abstract class AbstractMap<K,V> i
754              return eq(key, e.getKey()) && eq(value, e.getValue());
755          }
756  
757 +        /**
758 +         * Returns the hash code value for this map entry.  The hash code
759 +         * of a map entry {@code e} is defined to be: <pre>
760 +         *   (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
761 +         *   (e.getValue()==null ? 0 : e.getValue().hashCode())</pre>
762 +         * This ensures that {@code e1.equals(e2)} implies that
763 +         * {@code e1.hashCode()==e2.hashCode()} for any two Entries
764 +         * {@code e1} and {@code e2}, as required by the general
765 +         * contract of {@link Object#hashCode}.
766 +         *
767 +         * @return the hash code value for this map entry
768 +         * @see    #equals
769 +         */
770          public int hashCode() {
771              return (key   == null ? 0 :   key.hashCode()) ^
772                     (value == null ? 0 : value.hashCode());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines