_E_Collection interface has incorrect Javadoc

Issue #51 new
Jonathan Haas created an issue

The _E_Collection template contains the following interface/javadoc:

    // Comparison and hashing

    /**
     * Compares the specified object with this collection for equality.  Returns
     * <tt>true</tt> if the specified object is also a collection, the two collection
     * have the same size, and every member of the specified collection is
     * contained in this collection (or equivalently, every member of this collection is
     * contained in the specified collection).  This definition ensures that the
     * equals method works properly across different implementations of the
     * collection interface.
     *
     * @param o object to be compared for equality with this collection
     * @return <tt>true</tt> if the specified object is equal to this collection
     */
    boolean equals( Object o );


    /**
     * Returns the hash code value for this collection.  The hash code of a collection is
     * defined to be the sum of the hash codes of the elements in the collection.
     * This ensures that <tt>s1.equals(s2)</tt> implies that
     * <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
     * and <tt>s2</tt>, as required by the general contract of
     * {@link Object#hashCode}.
     *
     * @return the hash code value for this collection
     * @see Object#equals(Object)
     * @see Collection#equals(Object)
     */
    int hashCode();

But this javadoc definition doesn't make sense for Lists, which extend Collection.

In particular, this Javadoc is confusing, because TIntList(1,1,2) would equal to TIntList(1,2,3), but not in reverse. However the implementation of equals() and hashcode() for Lists is fine and just this Javadoc is wrong.

Comments (2)

  1. Log in to comment