List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
/** * //w w w . j av a2 s .co m */ public static <T> Set<T> toSet(T... values) { // Precondition checking if (values == null) { return new HashSet<T>(0); } // Set<T> r = new HashSet<T>(values.length); for (T t : values) { r.add(t); } return r; }
From source file:Main.java
/** * Returns a set containing the string representations of the elements in the collection * @param <T>/*from ww w . j av a2 s. c o m*/ * @param data * @return */ public static <T> Set<String> toStringSet(Collection<T> data) { Set<String> ret = new HashSet<String>(); for (T t : data) ret.add(t.toString()); return (ret); }
From source file:Main.java
/** * Adds the focus forward key.//from w w w . jav a2s . c o m * * @param button * the button */ public static void addFocusForwardKey(final int button) { final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); final Set<?> forwardKeys = manager .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set<KeyStroke> newForwardKeys = new HashSet(forwardKeys); newForwardKeys.add(KeyStroke.getKeyStroke(button, 0)); manager.setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys); }
From source file:Main.java
public static void registerNewSourceSinkConnection(int counter, String taintInfoOfSource) { Log.i("PEP", "in registerNewSourceSinkConnection(int counter, String taintInfoOfSource)" + counter + " " + taintInfoOfSource);//from ww w . j a va 2s .co m Set<String> taintInfos = new HashSet<String>(); taintInfos.add(taintInfoOfSource); sourceSinkConnection.put(counter, taintInfos); }
From source file:Main.java
/** * string convert to set/*w w w. j ava 2s. c om*/ */ public static Set<String> stringConvertToSet(String values, String separate) { if (values == null) { return null; } if (values.isEmpty()) { return Collections.EMPTY_SET; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; String[] sV = values.split(sp); Set<String> set = new HashSet<>(); for (String v : sV) { set.add(v); } return set; }
From source file:Main.java
public static <A> Set<A> setIntersection(Set<A> a, Set<A> b) { Set<A> set = new HashSet<A>(); for (A x : a) if (b.contains(x)) set.add(x); return set;/*from www .j a v a2 s.c o m*/ }
From source file:Main.java
public static Set<Integer> closedRange(int start, int end) { Set<Integer> range = new HashSet<Integer>(); for (int i = start; i <= end; i++) { range.add(i); }/*from ww w . ja v a 2 s. c o m*/ return range; }
From source file:Main.java
public static <T> Set<T> hashSetFromArray(final T[] objs) { final Set<T> set = new HashSet<T>(); for (final T obj : objs) { set.add(obj); }//from w ww. j a v a2 s . c om return set; }
From source file:Main.java
/** * byte[] convert to set/* w w w . j av a 2 s.c o m*/ */ public static Set<String> byteConvertToSet(byte[] blob, String separate) { if (blob == null) { return null; } if (blob.length == 0) { return Collections.EMPTY_SET; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; String values = new String(blob); String[] sV = values.split(sp); Set<String> set = new HashSet<>(); for (String v : sV) { set.add(v); } return set; }
From source file:de.unisb.cs.st.javalanche.mutation.util.FilePerformanceTest.java
private static Set<Integer> getSet(int limit) { Set<Integer> s = new HashSet<Integer>(); for (int i = 0; i < limit; i++) { s.add(r.nextInt()); }/* w w w . j ava 2s. c o m*/ return s; }