Fixed optimization logic error in containsAny.

Iteration should be over the smaller collection.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2003-09-22 02:20:56 +00:00
parent 129cc2869b
commit 949b9ffcb0
1 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CollectionUtils.java,v 1.43 2003/09/21 23:47:09 psteitz Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CollectionUtils.java,v 1.44 2003/09/22 02:20:56 psteitz Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -84,7 +84,7 @@ import org.apache.commons.collections.observed.ObservableCollection;
* Provides utility methods and decorators for {@link Collection} instances. * Provides utility methods and decorators for {@link Collection} instances.
* *
* @since Commons Collections 1.0 * @since Commons Collections 1.0
* @version $Revision: 1.43 $ $Date: 2003/09/21 23:47:09 $ * @version $Revision: 1.44 $ $Date: 2003/09/22 02:20:56 $
* *
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @author Paul Jack * @author Paul Jack
@ -239,7 +239,7 @@ public class CollectionUtils {
* @see #intersection * @see #intersection
*/ */
public static boolean containsAny(final Collection coll1, final Collection coll2) { public static boolean containsAny(final Collection coll1, final Collection coll2) {
if (coll1.size() > coll2.size()) { if (coll1.size() < coll2.size()) {
for (Iterator it = coll1.iterator(); it.hasNext();) { for (Iterator it = coll1.iterator(); it.hasNext();) {
if (coll2.contains(it.next())) { if (coll2.contains(it.next())) {
return true; return true;