List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
public static <K> Set<K> intersect(Collection<K> a, Collection<K> b) { Set<K> ret = new HashSet<K>(); for (K v : a) { if (b.contains(v)) ret.add(v); }// w w w. j a v a 2 s. c o m return ret; }
From source file:Main.java
public static Set<String> getNodeNames(Set<Node> nodes) { Set<String> names = new HashSet<String>(); for (Node node : nodes) { names.add(node.getLocalName()); }/* w ww.j ava 2 s.c o m*/ return names; }
From source file:Main.java
private static void exploreSuperInterfaces(Class<?> intf, Set<Class<?>> traitInterfaces) { for (Class<?> sup : intf.getInterfaces()) { traitInterfaces.add(sup); exploreSuperInterfaces(sup, traitInterfaces); }//w w w .j ava2s. c om }
From source file:Main.java
public static <T> Set<T> asSet(T[] array) { final Set<T> set = new HashSet<T>(array.length); for (T e : array) { set.add(e); }/*w w w. j a v a 2s. c om*/ return set; }
From source file:Main.java
public static Set<QName> getNodeTypes(Set<Node> nodes) { Set<QName> names = new HashSet<QName>(); for (Node node : nodes) { names.add(nodeToQName(node)); }/*from w ww .j av a 2 s. com*/ return names; }
From source file:Main.java
/** * Build an set./*w w w .ja va 2s . c om*/ * * @param values * Values to be added in a set. * @return A set containing all given values. */ @SafeVarargs public static <T> Set<T> asSet(T... values) { if (values == null || values.length == 0) { return Collections.emptySet(); } else { // A lit bit higher than load factor int size = (int) Math.floor(values.length * 1.4); Set<T> set = new HashSet<>(size); for (T value : values) { set.add(value); } return set; } }
From source file:de.tudarmstadt.ukp.dkpro.spelling.experiments.data.CreateVocabularyFromCorpus.java
private static void createVocabulary(Corpus corpus) throws Exception { Set<String> vocabulary = new TreeSet<String>(); for (String token : corpus.getTokens()) { vocabulary.add(token); }/*from www . j av a 2s . co m*/ StringBuilder sb = new StringBuilder(); for (String item : vocabulary) { sb.append(item); sb.append(System.getProperty("line.separator")); } FileUtils.writeStringToFile(new File("target/" + corpus.getName() + ".txt"), sb.toString()); }
From source file:Main.java
/** * Converts parameters into a set/*from w ww .ja v a 2s. c om*/ * * @param <T> set element type * @param value element * @return set containing the given elements */ public static <T> Set<T> asSet(T value) { Set<T> set = new HashSet<>(1); set.add(value); return set; }
From source file:Main.java
public static Set<Character> arrayToSet(char[] array) { Set<Character> arraySet = new HashSet<Character>(); for (Character character : arraySet) { arraySet.add(character); }/* w w w .java2s .c om*/ return arraySet; }
From source file:Main.java
/** * Converts parameters into a set/*from w w w.j a v a 2s .co m*/ * * @param <T> set element type * @param first element * @param second element * @return set containing the given elements */ public static <T> Set<T> asSet(T first, T second) { Set<T> set = new HashSet<>(2); set.add(first); set.add(second); return set; }