List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
/** * Adds the value to map. If the key does not exists new value set is created and the value is * added to it/*from ww w . j a va 2 s .c o m*/ * * @param <K> * the key type * @param <V> * the value type * @param map * the map * @param key * the key * @param newValue * the new value */ public static <K, V> void addValueToSetMap(Map<K, Set<V>> map, K key, V newValue) { Set<V> list = map.get(key); if (list == null) { list = new LinkedHashSet<V>(); map.put(key, list); } list.add(newValue); }
From source file:Main.java
public static void deleteFaces(List<String> faceIdsToDelete, String personId, Context context) { Set<String> faceIds = getAllFaceIds(personId, context); Set<String> newFaceIds = new HashSet<>(); for (String faceId : faceIds) { if (!faceIdsToDelete.contains(faceId)) { newFaceIds.add(faceId); }/* ww w. j av a 2 s. com*/ } SharedPreferences faceIdSet = context.getSharedPreferences(personId + "FaceIdSet", Context.MODE_PRIVATE); SharedPreferences.Editor faceIdSetEditor = faceIdSet.edit(); faceIdSetEditor.putStringSet("FaceIdSet", newFaceIds); faceIdSetEditor.commit(); }
From source file:Main.java
/** * //from ww w . ja v a 2 s. com * */ public static <T> boolean equalsAsSet(Collection<T> value1, Collection<T> value2) { Set<Object> s1 = new HashSet<Object>(); for (Object v : value1) { s1.add(v); } Set<Object> s2 = new HashSet<Object>(); for (Object v : value2) { s2.add(v); } return s1.equals(s2); }
From source file:com.blackducksoftware.integration.hub.detect.workflow.report.util.ObjectPrinter.java
private static Set<Class<?>> getNonNestedTypes() { final Set<Class<?>> ret = new HashSet<>(); ret.add(File.class); ret.add(String.class); ret.add(Boolean.class); ret.add(Character.class); ret.add(Byte.class); ret.add(Short.class); ret.add(Integer.class); ret.add(Long.class); ret.add(Float.class); ret.add(Double.class); ret.add(Void.class); ret.add(Optional.class); return ret;/* www . j av a 2 s .c o m*/ }
From source file:de.unisb.cs.st.javalanche.mutation.hibernate.CoverageDataTest.java
private static Set<String> getTests() { Set<String> result = new HashSet<String>(); for (int i = 0; i < TESTS; i++) { result.add("TEST_" + i); }/*from w w w . j a v a 2 s. c o m*/ return result; }
From source file:Main.java
/** * Look up giving map for giving value collect pick all suitable keys * @param map//w w w . ja v a2s .c o m * @param value * @return ste of keys mapped to the giving value */ public static <T, E> Set<T> getKeysByValue(Map<T, E> map, E value) { Set<T> keys = new HashSet<T>(); for (Map.Entry<T, E> entry : map.entrySet()) { if (value.equals(entry.getValue())) { keys.add(entry.getKey()); } } return keys; }
From source file:de.perdian.apps.dashboard.mvc.modules.pingdom.PingdomController.java
private static Set<String> createIdentifierSet(String identifiers) { JsonNode identifiersNode = JsonUtil.fromJsonString(identifiers); Set<String> result = new LinkedHashSet<>(); for (int i = 0; i < identifiersNode.size(); i++) { result.add(identifiersNode.get(i).asText()); }//from ww w.jav a2 s. c o m return result; }
From source file:co.turnus.analysis.util.AnalysisUtil.java
public static int[] linspacei(int min, int max) { Set<Integer> values = new LinkedHashSet<Integer>(); for (int i = min; i <= max; i++) { values.add(i); }//ww w.j a v a 2 s . c o m return ArrayUtils.toPrimitive(values.toArray(new Integer[0])); }
From source file:Main.java
/** * Add a varargs list of items into a set. If the set or items are null then no action is performed. Note that the * destination set has no requirements other than it must be a Set of the source item's type. This allows the * destination to be used, for example, as an accumulator.<br> * <br>//from w w w.j a v a2s . com * Note that this method is not thread safe. Users of this method will need to maintain type safety against the set. * * @param set * A set to which items will be added * @param items * A list of items to add */ public static final <T, U extends T> Set<T> addToSet(Set<T> set, U... items) { if (set != null && items != null) { for (int i = 0; i < items.length; i++) { set.add(items[i]); } } return set; }
From source file:org.hawkular.alerts.actions.api.model.JsonTest.java
@BeforeClass public static void initTest() { Trigger trigger = new Trigger(TEST_TENANT, "trigger-test", "trigger-test"); Alert alert = new Alert(TEST_TENANT, trigger, null); AvailabilityCondition aCond = new AvailabilityCondition(TEST_TENANT, "trigger-test", "Default", AvailabilityCondition.Operator.UP); Data aData = Data.forAvailability(TEST_TENANT, "Metric-test", 1, AvailabilityType.UP); AvailabilityConditionEval aEval = new AvailabilityConditionEval(aCond, aData); ThresholdCondition tCond = new ThresholdCondition(TEST_TENANT, "trigger-test", "Default", ThresholdCondition.Operator.LTE, 50.0); Data tData = Data.forNumeric(TEST_TENANT, "Metric-test2", 2, 25.5); ThresholdConditionEval tEval = new ThresholdConditionEval(tCond, tData); Set<ConditionEval> evals = new HashSet<>(); evals.add(aEval); evals.add(tEval);/*from ww w . j a va2s . com*/ List<Set<ConditionEval>> list = new ArrayList<>(); list.add(evals); alert.setEvalSets(list); incomingAction = new Action(TEST_TENANT, "testPlugin", "testActionId", alert); Map<String, String> props = new HashMap<>(); props.put("k1", "v1"); props.put("k2", "v2"); incomingAction.setProperties(props); }