List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
public static Set toSet(String... values) { Set<Object> set = new HashSet(); for (String value : values) { set.add(value); }/*from w w w . ja va 2s . c o m*/ return set; }
From source file:Main.java
/** * Returns set of string. This is a convenient method for adding a set of * string into a map. In this project, we usually have the * <code>Map<String, Set<String>> and many times, we just * want to add a string to the map.// w w w. j a va 2 s . c o m * * @param key Key to the entry in the map. * @param map Map of String to Set of String. * @param value Value to be added to the map referenced by <code>key</code>. * @return Set of string. */ public static Set<String> putSetIntoMap(String key, Map<String, Set<String>> map, String value) { Set<String> set = new HashSet<String>(); set.add(value); map.put(key, set); return set; }
From source file:Main.java
public static void setComponentTraversalKeys(int direction, JComponent component, KeyStroke stroke) { Set<AWTKeyStroke> forwardKeys = component.getFocusTraversalKeys(direction); Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(forwardKeys); newForwardKeys.add(stroke); component.setFocusTraversalKeys(direction, newForwardKeys); }
From source file:Main.java
private static void collectAssignables(Class c1, Class c2, Set s) { if (c1.isAssignableFrom(c2)) { s.add(c1); }//from ww w.j a v a 2s . com Class sc = c1.getSuperclass(); if (sc != null) { collectAssignables(sc, c2, s); } Class[] itf = c1.getInterfaces(); for (int i = 0; i < itf.length; ++i) { collectAssignables(itf[i], c2, s); } }
From source file:Main.java
public static Set toSet(String... values) { Set<Object> set = new HashSet<>(); for (String value : values) { set.add(value); }//from w ww . ja va2 s .co m return set; }
From source file:Main.java
public static <T> Set<T> newHashSet(T... objs) { Set<T> result = new HashSet<T>(); for (T o : objs) { result.add(o); }//from w w w. ja v a 2 s .c o m return result; }
From source file:Main.java
public static <E> Set<E> toSet(Iterable<? extends E> iterable) { final Set<E> set = new HashSet<E>(); for (E e : iterable) { set.add(e); }//from ww w . j a va 2 s. c o m return Collections.unmodifiableSet(set); }
From source file:Main.java
public static <T> Set<T> asSet(T... args) { Set<T> newSet = new HashSet<T>(args.length); for (T arg : args) { newSet.add(arg); }//w ww. j a v a2s. co m return newSet; }
From source file:Main.java
public static <T> Set<T> asSet(final T t, final T... ts) { final Set<T> set = new HashSet<T>(ts.length + 1); set.add(t); Collections.addAll(set, ts);/* w w w . j a v a 2 s . c o m*/ return set; }
From source file:Main.java
public static <C extends Set<T>, T> Set<T> toSet(T[] array, Class<C> clazz) { try {/*from w w w . j a va 2s . com*/ Set<T> set = clazz.newInstance(); for (T o : array) { set.add(o); } return set; } catch (Exception e) { return null; } }