Java Collection Contain containsAll(Collection coll, Collection other)

Here you can find the source of containsAll(Collection coll, Collection other)

Description

contains All

License

Open Source License

Return

whether given coll contains all elements of other, using a naive/basic algorithm.

Declaration

public static boolean containsAll(Collection<?> coll,
        Collection<?> other) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007 DSource.org and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  ww  w .ja v  a  2 s.c om*/
 *     Bruno Medeiros - initial implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    /** @return whether given coll contains all elements of other, using a naive/basic algorithm. */
    public static boolean containsAll(Collection<?> coll,
            Collection<?> other) {
        for (Object otherElement : other) {
            if (!coll.contains(otherElement))
                return false;
        }
        return true;
    }
}

Related

  1. contains(Collection collection, T item)
  2. contains(final Collection mimeTypes, final MimeType mimeType)
  3. contains(final Collection c, final T o)
  4. contains(Object o, Collection c)
  5. containsAll(Collection c, Iterable subset)
  6. containsAll(Collection collectionToCheck, Collection items)
  7. containsAll(final Collection c, final Object... array)
  8. containsAll(final Collection coll1, final Collection coll2)
  9. containSameElements(Collection> sets)