List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:Main.java
public static <V> void appendMaps(Map<Integer, V> A, Map<Integer, V> B) { int index = A.size(); for (int i : B.keySet()) { A.put(index, B.get(i));/*from w w w .ja v a2 s. co m*/ index++; } }
From source file:Main.java
/** * Make a list map immutable./* www .ja v a 2s . com*/ * * @param listMap * the list map in input. * @return the immutable list map. */ public static <C, E> Map<C, List<E>> makeListMapImmutable(Map<C, List<E>> listMap) { for (C key : listMap.keySet()) { listMap.put(key, Collections.unmodifiableList(listMap.get(key))); } return Collections.unmodifiableMap(listMap); }
From source file:Main.java
public static void listKeys(Map<String, String> map) { System.out.println("Key Set:"); Set<String> keys = map.keySet(); keys.forEach(System.out::println); System.out.println();/* w w w.ja v a 2s .c om*/ }
From source file:Main.java
public static void dumpCurrentSharedPrerence(SharedPreferences pref) { Map<String, ?> map = pref.getAll(); Iterator<String> ite = map.keySet().iterator(); while (ite.hasNext()) { String key = ite.next();/*from w w w .ja va 2 s . c om*/ Log.d(TAG, "dump " + key + " : " + String.valueOf(map.get(key))); } }
From source file:Main.java
/** * Returns map keys list./*from www. j a v a 2s .com*/ * * @param map * map to process * @param <K> * key object type * @param <V> * value object type * @return map keys list */ public static <K, V> ArrayList<K> keysList(final Map<K, V> map) { return new ArrayList<K>(map.keySet()); }
From source file:Main.java
private static void print(String text, Map<String, Double> map) { System.out.println(text);/*ww w.java 2s .com*/ for (String key : map.keySet()) { System.out.println("key/value: " + key + "/" + map.get(key)); } }
From source file:Main.java
/** * Applies a function to the keys of the map. Note: Uses a for-each loop. * * @param map The map with the keys the function will be applied to. * @param function The function to apply. *//*from www . j a v a 2 s .c o m*/ public static <I, K extends I> void applyToKeys(Map<K, ?> map, Function<I, ?> function) { for (K key : map.keySet()) function.apply(key); }
From source file:Main.java
/** Take key and value pairs from source and create map from value to key in target. */ public static <K, V> void reverse(Map<K, V> source, Map<V, K> target) { Iterator<K> i = source.keySet().iterator(); while (i.hasNext()) { K key = i.next();// w w w . j av a2 s . c o m V value = source.get(key); target.put(value, key); } }
From source file:Main.java
public static void clearNullElement(Map map) { if (map == null) return;/*from ww w.j ava 2 s .c om*/ Object[] vs = map.keySet().toArray(); for (Object o : vs) { if (null == map.get(o)) map.remove(o); } }
From source file:Main.java
public static void clearNullElement(Map<?, ?> map) { if (map == null) return;/*from ww w .j a v a2 s. c om*/ Object[] vs = map.keySet().toArray(); for (Object o : vs) { if (null == map.get(o)) map.remove(o); } }