All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.berkeley.nlp.util.SetUtils Maven / Gradle / Ivy

Go to download

The Berkeley parser analyzes the grammatical structure of natural language using probabilistic context-free grammars (PCFGs).

The newest version!
package edu.berkeley.nlp.util;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * User: aria42
 * Date: Mar 29, 2009
 */
public class SetUtils {
  public static  Set intersection(Factory> fact, Collection...sets) {
    Set result = fact.newInstance();
    if (sets.length == 0) return result;
    result.addAll(sets[0]);
    for (int i = 1; i < sets.length; i++) {
      result.retainAll(sets[i]);
    }
    return result;
  }

  public static  Set intersection(Collection...sets) {
    return intersection(new Factory.DefaultFactory>(HashSet.class),sets);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy