List of utility methods to do Map Reverse
Map | reverse(Map Returns a new map that contains the reverse of the given map. Map<T, T> target = new HashMap<T, T>(); for (Entry<T, T> entry : source.entrySet()) { target.put(entry.getValue(), entry.getKey()); return target; |
HashMap | reverse_map(Map "{:a 1 :b 1 :c 2} -> {1 [:a :b] 2 :c}" HashMap<V, List<K>> rtn = new HashMap<V, List<K>>(); if (map == null) { return rtn; for (Entry<K, V> entry : map.entrySet()) { K key = entry.getKey(); V val = entry.getValue(); List<K> list = rtn.get(val); ... |
HashMap | reverse_map(Map "{:a 1 :b 1 :c 2} -> {1 [:a :b] 2 :c}" HashMap<V, List<K>> rtn = new HashMap<V, List<K>>(); if (map == null) { return rtn; for (Entry<K, V> entry : map.entrySet()) { K key = entry.getKey(); V val = entry.getValue(); List<K> list = rtn.get(val); ... |
Map | reverseKeyAndValue(Map map) reverse Key And Value Map reverseMap = new HashMap(); for (Entry entry : (Set<Entry>) map.entrySet()) { reverseMap.put(entry.getValue(), entry.getKey()); return reverseMap; |
Map | reverseLabelMap(Map reverse Label Map Map<Double, T> revMap = new HashMap<Double, T>(); for (T k : labelMap.keySet()) { revMap.put(labelMap.get(k), k); return revMap; |
HashMap | reverseMap(List listSeq) "[[:a 1] [:b 1] [:c 2]} -> {1 [:a :b] 2 :c}" Reverses an assoc-list style Map like reverseMap(Map...) HashMap<Object, List<Object>> rtn = new HashMap(); if (listSeq == null) { return rtn; for (Object entry : listSeq) { List listEntry = (List) entry; Object key = listEntry.get(0); Object val = listEntry.get(1); ... |
Map | reverseMap(Map Returns a map where the keys are the values of the map argument and the values are the corresponding keys. HashMap<V, K> reversed = new HashMap<V, K>(); Set<Entry<K, V>> entries = map.entrySet(); for (Entry<K, V> entry : entries) { reversed.put(entry.getValue(), entry.getKey()); return reversed; |
Map | reverseMap(Map reverse Map Map<V, K> ret = new HashMap<V, K>(); for (K key : map.keySet()) { ret.put(map.get(key), key); return ret; |
Map | reverseMap(Map reverse Map Map<V, K> ret = new HashMap<V, K>(); for (K key : map.keySet()) { ret.put(map.get(key), key); return ret; |
HashMap | reverseMap(Map Reverses a map into a HashMap . HashMap<V, K> result = new HashMap<V, K>(); for (Map.Entry<K, V> entry : map.entrySet()) { V key = entry.getValue(); if (result.containsKey(key)) { throw new IllegalArgumentException("Key already present."); result.put(key, entry.getKey()); return result; |