Java Utililty Methods Set sub set

List of utility methods to do Set sub set

Description

The list of methods to do Set sub set are organized into topic(s).

Method

StringgetFirstSubString(String s, Set delimiters)
get First Sub String
if (s == null)
    return null;
String sub = s.trim();
int endIndex = -1;
if (delimiters != null) {
    Iterator<String> iter = delimiters.iterator();
    while (iter.hasNext()) {
        String delimiter = iter.next();
...
List>getSubsets(Set set)
get Subsets
List<Set<T>> subsets = new ArrayList<Set<T>>();
List<T> list = new ArrayList<T>(set);
int numOfSubsets = 1 << set.size();
for (int i = 0; i < numOfSubsets; i++) {
    Set<T> subset = new HashSet<T>();
    for (int j = 0; j < numOfSubsets; j++) {
        if (((i >> j) & 1) == 1) {
            subset.add(list.get(j));
...
List>split(Set original, int subsetSize)
Split a set into subsets
if (subsetSize <= 0) {
    throw new IllegalArgumentException("Incorrect max size");
if (original == null || original.isEmpty()) {
    return Collections.emptyList();
int subsetCount = (int) (Math.ceil((double) original.size() / subsetSize));
ArrayList<Set<T>> subsets = new ArrayList<Set<T>>(subsetCount);
...
Setsub(Set a, Set b)
sub
if (a == null)
    return Collections.EMPTY_SET;
if (b == null)
    return new HashSet<Object>(a);
Set<Object> sub = new HashSet<Object>();
for (Object obj : a) {
    if (!b.contains(obj))
        sub.add(obj);
...
double[]subset(double[] vals, boolean[] select)
subset
assert vals.length == select.length;
List<Double> list = new ArrayList<Double>();
for (int i = 0; i < vals.length; i++) {
    if (select[i] && !Double.isNaN(vals[i]))
        list.add(vals[i]);
double[] sub = new double[list.size()];
int i = 0;
...
booleansubset(Set sub, Set sup)
Checks if one set is subset of another one
for (Iterator i = sub.iterator(); i.hasNext();) {
    if (!sup.contains(i.next()))
        return false;
return true;
SetsubSet(Set nn, T n)
sub Set
Set<T> result = new HashSet<T>(nn);
result.remove(n);
return result;