Java Set sub set subset(Set sub, Set sup)

Here you can find the source of subset(Set sub, Set sup)

Description

Checks if one set is subset of another one

License

Open Source License

Parameter

Parameter Description
sub a parameter
sup a parameter

Declaration

public static boolean subset(Set sub, Set sup) 

Method Source Code

//package com.java2s;
//The MIT License

import java.util.Iterator;
import java.util.Set;

public class Main {
    /**/* w  w w.ja  v a2 s.c  o m*/
     * Checks if one set is subset of another one
     * 
     * @param sub
     * @param sup
     * @return
     */
    public static boolean subset(Set sub, Set sup) {
        for (Iterator i = sub.iterator(); i.hasNext();) {
            if (!sup.contains(i.next()))
                return false;
        }

        return true;
    }
}

Related

  1. getFirstSubString(String s, Set delimiters)
  2. getSubsets(Set set)
  3. split(Set original, int subsetSize)
  4. sub(Set a, Set b)
  5. subset(double[] vals, boolean[] select)
  6. subSet(Set nn, T n)