Java Set Search containsAny(Set container, Set possibilities)

Here you can find the source of containsAny(Set container, Set possibilities)

Description

contains Any

License

Open Source License

Declaration

public static <T> boolean containsAny(Set<T> container, Set<T> possibilities) 

Method Source Code

//package com.java2s;
/**//from w w w . j  av  a2 s  .c o m
 * Utilities.java
 * ---------------------------------
 * Copyright (c) 2014
 * RESOLVE Software Research Group
 * School of Computing
 * Clemson University
 * All rights reserved.
 * ---------------------------------
 * This file is subject to the terms and conditions defined in
 * file 'LICENSE.txt', which is part of this source code package.
 */

import java.util.Iterator;

import java.util.Set;

public class Main {
    public static <T> boolean containsAny(Set<T> container, Set<T> possibilities) {
        boolean result = false;

        Iterator<T> possibilitiesIter = possibilities.iterator();
        while (!result && possibilitiesIter.hasNext()) {
            result = container.contains(possibilitiesIter.next());
        }

        return result;
    }
}

Related

  1. contains(BitSet x, BitSet y)
  2. Contains(Set s, Object o)
  3. contains(Set setTocheck, Set mustHaveAllThese)
  4. containsCaseInsensitive(String s, Set l)
  5. containsSome(Set one, Set two)