You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marcus Crafter <cr...@managesoft.com> on 2004/11/09 12:54:19 UTC

Comparing 2 lists via contents?

Hi All,

Hope all is going well.

I'm looking for a particular method in List or Collection Utils but 
can't find it, must be going blind! ;)

I've got 2 lists, containing objects that are equal by value but not 
equal by reference (ie. a.equals(b) is true, but a == b is false).

CollectionUtils.isEqualsCollection(Collection, Collection) seems to work 
by comparing whether the objects are equal by reference, ie. whether a 
== b is true.

Is there something similar for comparing the contents of 2 lists by 
value, perhaps somewhere that I've missed?

Cheers,

Marcus



-- 
         .....
      ,,$$$$$$$$$,      Marcus Crafter
     ;$'      '$$$$:    Computer Systems Engineer
     $:         $$$$:   ManageSoft Corporation
      $       o_)$$$:   Frankfurt am Main, Germany
      ;$,    _/\ &&:'
        '     /( &&&
            \_&&&&'
           &&&&.
     &&&&&&&:

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


Re: Comparing 2 lists via contents?

Posted by Marcus Crafter <cr...@managesoft.com>.
arrgghh.. *head bouncing off the wall*... thanks for pointing out the 
obvious mate :)

Cheers,

Marcus

Christoph Gaffga (triplemind.com) wrote:
> have you tried:
> 
> collection1.equals(collection2)
> 
> I think, that was it.
> 
> regards,
> Christoph Gaffga
> cgaffga@triplemind.com
> 
> ----- Original Message ----- 
> From: "Marcus Crafter" <cr...@managesoft.com>
> Newsgroups: gmane.comp.jakarta.commons.user
> Sent: Tuesday, November 09, 2004 12:54 PM
> Subject: Comparing 2 lists via contents?
> 
> 
> 
>>Hi All,
>>
>>Hope all is going well.
>>
>>I'm looking for a particular method in List or Collection Utils but 
>>can't find it, must be going blind! ;)
>>
>>I've got 2 lists, containing objects that are equal by value but not 
>>equal by reference (ie. a.equals(b) is true, but a == b is false).
>>
>>CollectionUtils.isEqualsCollection(Collection, Collection) seems to work 
>>by comparing whether the objects are equal by reference, ie. whether a 
>>== b is true.
>>
>>Is there something similar for comparing the contents of 2 lists by 
>>value, perhaps somewhere that I've missed?
>>
>>Cheers,
>>
>>Marcus
>>
>>
>>
>>-- 
>>         .....
>>      ,,$$$$$$$$$,      Marcus Crafter
>>     ;$'      '$$$$:    Computer Systems Engineer
>>     $:         $$$$:   ManageSoft Corporation
>>      $       o_)$$$:   Frankfurt am Main, Germany
>>      ;$,    _/\ &&:'
>>        '     /( &&&
>>            \_&&&&'
>>           &&&&.
>>     &&&&&&&:
> 
> 

-- 
         .....
      ,,$$$$$$$$$,      Marcus Crafter
     ;$'      '$$$$:    Computer Systems Engineer
     $:         $$$$:   ManageSoft Corporation
      $       o_)$$$:   Frankfurt am Main, Germany
      ;$,    _/\ &&:'
        '     /( &&&
            \_&&&&'
           &&&&.
     &&&&&&&:

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


Re: Comparing 2 lists via contents?

Posted by "Christoph Gaffga (triplemind.com)" <cg...@triplemind.com>.
have you tried:

collection1.equals(collection2)

I think, that was it.

regards,
Christoph Gaffga
cgaffga@triplemind.com

----- Original Message ----- 
From: "Marcus Crafter" <cr...@managesoft.com>
Newsgroups: gmane.comp.jakarta.commons.user
Sent: Tuesday, November 09, 2004 12:54 PM
Subject: Comparing 2 lists via contents?


> Hi All,
> 
> Hope all is going well.
> 
> I'm looking for a particular method in List or Collection Utils but 
> can't find it, must be going blind! ;)
> 
> I've got 2 lists, containing objects that are equal by value but not 
> equal by reference (ie. a.equals(b) is true, but a == b is false).
> 
> CollectionUtils.isEqualsCollection(Collection, Collection) seems to work 
> by comparing whether the objects are equal by reference, ie. whether a 
> == b is true.
> 
> Is there something similar for comparing the contents of 2 lists by 
> value, perhaps somewhere that I've missed?
> 
> Cheers,
> 
> Marcus
> 
> 
> 
> -- 
>          .....
>       ,,$$$$$$$$$,      Marcus Crafter
>      ;$'      '$$$$:    Computer Systems Engineer
>      $:         $$$$:   ManageSoft Corporation
>       $       o_)$$$:   Frankfurt am Main, Germany
>       ;$,    _/\ &&:'
>         '     /( &&&
>             \_&&&&'
>            &&&&.
>      &&&&&&&:


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


AW: Comparing 2 lists via contents?

Posted by Stephan Schweitzer <sc...@inferenzsysteme.informatik.tu-darmstadt.de>.
> Hi All,
> 
> Hope all is going well.
> 
> I'm looking for a particular method in List or Collection Utils but
> can't find it, must be going blind! ;)
> 
> I've got 2 lists, containing objects that are equal by value but not
> equal by reference (ie. a.equals(b) is true, but a == b is false).
> 
> CollectionUtils.isEqualsCollection(Collection, Collection) seems to
work
> by comparing whether the objects are equal by reference, ie. whether a
> == b is true.
> 
> Is there something similar for comparing the contents of 2 lists by
> value, perhaps somewhere that I've missed?

the normal equals-method of list will compare to lists by calling the 
equals-methods of the elements. thus this is exactly the method you 
are looking for I guess ;-)


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