List of utility methods to do Map Invert
Map | invertMap(final Map Inverts the supplied map returning a new HashMap such that the keys of the input are swapped with the values. final Map<V, K> out = new HashMap<V, K>(map.size()); for (final Entry<K, V> entry : map.entrySet()) { out.put(entry.getValue(), entry.getKey()); return out; |
Map | invertMap(final Map invert Map final Map<V, K> inverted = new IdentityHashMap<>(map.size()); for (final Map.Entry<K, V> entry : map.entrySet()) { inverted.put(entry.getValue(), entry.getKey()); return Collections.unmodifiableMap(inverted); |
Map | invertMap(Map map) Inverts the supplied map returning a new HashMap such that the keys of the input are swapped with the values. Map out = new HashMap(map.size()); for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); out.put(entry.getValue(), entry.getKey()); return out; |
Map | invertMap(Map map) Inverts the supplied map returning a new HashMap such that the keys of the input are swapped with the values. Map out = new HashMap(map.size()); for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); out.put(entry.getValue(), entry.getKey()); return out; |
Map | invertMap(Map invert Map Map<V, K> inverted = new HashMap<V, K>(); for (Map.Entry<K, V> entry : map.entrySet()) { inverted.put(entry.getValue(), entry.getKey()); return inverted; |
Map | invertMap(Map Invert map. Map<V, K> inv = new HashMap<V, K>(); for (Entry<K, V> entry : map.entrySet()) inv.put(entry.getValue(), entry.getKey()); return inv; |
Map | invertMap(Map Inverts the given map from key-value mappings to value-key mappings Note: this may have unintended results if a certain value is included in the map more than once Map<V, K> inverted = new HashMap<V, K>(); for (Map.Entry<K, V> entry : map.entrySet()) { inverted.put(entry.getValue(), entry.getKey()); return inverted; |
HashMap | invertStringMap(Map Inverts Map of Strings (values become keys, keys become values). HashMap<String, String> output = new HashMap<String, String>(input.size()); Set<Map.Entry<String, String>> entries = input.entrySet(); for (Map.Entry<String, String> entry : entries) { output.put(entry.getValue(), entry.getKey()); return output; |