You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2003/12/24 22:15:29 UTC

[collectiions] [proposal] Bag interface change

I am proposing to change the Bag interface.
http://jakarta.apache.org/commons/collections/api/org/apache/commons/collect
ions/Bag.html

Add:
equals(Object) - Two Bags are equal if they contain the same number of
occurrences of all the same elements.
hashCode() - The hashCode is defined as the sum total of each elements
hashcode, where the hashcode for an element is defined as (e==null   ? 0 :
e.hashCode()) ^ noOccurances)

This will enable Bags to be compared.

I am tempted to change the rest of the interface, to fix the violations of
Collection, however that is probably a bad idea.

Stephen





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [collections] [proposal] Bag interface change

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Change subject so it passes mail filters ;-)

From: "Stephen Colebourne" <sc...@btopenworld.com>
> I am proposing to change the Bag interface.
>
http://jakarta.apache.org/commons/collections/api/org/apache/commons/collect
> ions/Bag.html
>
> Add:
> equals(Object) - Two Bags are equal if they contain the same number of
> occurrences of all the same elements.
> hashCode() - The hashCode is defined as the sum total of each elements
> hashcode, where the hashcode for an element is defined as (e==null   ? 0 :
> e.hashCode()) ^ noOccurances)
>
> This will enable Bags to be compared.
>
> I am tempted to change the rest of the interface, to fix the violations of
> Collection, however that is probably a bad idea.
>
> Stephen



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org