List of usage examples for java.util HashMap get
public V get(Object key)
From source file:Main.java
public static Object get(String key) { HashMap map = (HashMap) s_var.get(); if (map == null) throw new IllegalStateException("Thread local not exists!"); else//from w w w .j a v a 2 s. co m return map.get(key); }
From source file:Main.java
public static void shiftTableIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, long topTableId) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/*ww w .j a va 2 s . c o m*/ } for (ContentValues restoreCv : restoreOperations) { restoreCv.put(idColumnName, restoreCv.getAsLong(idColumnName) + topTableId); } }
From source file:Main.java
public static Object keyString(HashMap<String, String> map, String o) { Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { Object keyString = it.next(); if (map.get(keyString).equals(o)) return keyString; }//from w ww . j a va2 s . c o m return null; }
From source file:Main.java
/** * Returns a {@link Map} mapping each unique element in * the given {@link Collection} to an {@link Integer} * representing the number of occurances of that element * in the {@link Collection}./*w ww .ja v a 2 s .c o m*/ * An entry that maps to <tt>null</tt> indicates that the * element does not appear in the given {@link Collection}. * @param col The collection to count cardinalities for * @return A map of counts, indexed on each element in the collection */ public static <E> Map<E, Integer> getCardinalityMap(final Collection<E> col) { HashMap<E, Integer> count = new HashMap<E, Integer>(); for (E obj : col) { Integer c = count.get(obj); if (null == c) { count.put(obj, 1); } else { count.put(obj, c + 1); } } return count; }
From source file:Main.java
public static void printDictionary(HashMap<Integer, String> dict) { System.out.println("Index\t\tEntry\n---------------------"); for (int i = 0; i < dict.size(); i++) { System.out.println(i + "\t\t" + dict.get(i)); }/*from w ww .ja v a 2 s .c om*/ }
From source file:org.mycontroller.standalone.settings.MetricsGraph.java
public static MetricsGraph get(HashMap<String, Object> gMap) { return MetricsGraph.builder().type((String) gMap.get(SensorVariable.KEY_GP_TYPE)) .interpolate((String) gMap.get(SensorVariable.KEY_GP_INTERPOLATE)) .subType((String) gMap.get(SensorVariable.KEY_GP_SUBTYPE)) .color((String) gMap.get(SensorVariable.KEY_GP_COLOR)).build(); }
From source file:Main.java
private static HashMap<Integer, HashMap<Integer, Integer>> removeMinute(int startMinute, int endMinute, int keyHour, HashMap<Integer, HashMap<Integer, Integer>> hashMap) { HashMap<Integer, Integer> values = hashMap.get(keyHour); for (int i = startMinute; i < endMinute + 1; i++) { values.remove(i);//from www .ja va 2 s.com } // hashMap.remove(keyHour); // hashMap.put(keyHour, values); return hashMap; }
From source file:it.acubelab.smaph.entityfilters.LibSvmEntityFilter.java
private static double getOrDefault(HashMap<String, Double> features, String key, double defaultVal) { Double res = features.get(key); if (res == null) return defaultVal; return res;/*from w ww .j a va 2s . c om*/ }
From source file:Main.java
/** * The security value is the sum of deviations between the distance * of one specific place and all the other ones in the placeDistanceMap. * * @param distanceAtOnePlace the distance for one specific place * @param placeDistanceMap the place distance map that the single gets compared to * @return the double value of the sum of deviation, also called "security value" *//*from ww w . j av a2 s . c o m*/ public static double securityValue(double distanceAtOnePlace, HashMap<String, Double> placeDistanceMap) { double sumDeviation = 0; for (String key : placeDistanceMap.keySet()) { sumDeviation += Math.abs(distanceAtOnePlace - placeDistanceMap.get(key)); } return sumDeviation; }
From source file:Main.java
public static HashMap<String, Integer> getMostFrequentDestination(ArrayList<String> destination) { System.out.println("ARRAYLIST INPUT! : " + destination.size()); HashMap<String, Integer> temp = new HashMap<String, Integer>(); for (String d : destination) { if (temp.containsKey(d)) { temp.put(d, temp.get(d) + 1); } else {//from w w w. ja v a 2s . c o m temp.put(d, 1); } } return temp; }