commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernhard Wagner" ...@xmlizer.biz>
Subject RE: Removing duplicates from a Collection
Date Mon, 12 May 2003 15:33:10 GMT
If you consider implementing equals bear in mind that:
If equals() returns true for two objects, both objects must return the same
integer from the hashCode() method.

Check e.g. http://www.vipan.com/htdocs/hashcode_help.html for background
info.

Bernhard

> -----Original Message-----
> From: Adam Sherman [mailto:adam@tritus.ca]
> Sent: Montag, 12. Mai 2003 15:46
> To: Dmitry Sklyut
> Cc: Jakarta Commons Users List
> Subject: RE: Removing duplicates from a Collection
>
>
> On 05/12/03 06:36:16 -0700 Dmitry Sklyut wrote:
>
> > why don't you do:
> >
> > List l;
> > Set s;
> >
> > s.addAll(l);
> >
> > That should do the trick.
>
> Heh. That looks too simple. Actually, my needs are slightly
> complicated in
> how I define "duplicate" is wierd.
>
> The items have three properties but only one of them is important and
> defines uniqueness of the item. So I suppose that I could implement
> Object.equals() on the item and get the desired result, yes?
>
> Also, this is a collection with upwards of 50K items in it. Will this be
> performant?
>
> Thanks very much for your suggestions,
>
> A.
>
> --
> Adam Sherman
> Tritus CG Inc.
> http://www.tritus.ca/
> +1 (613) 797-6819
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


Mime
View raw message