List of utility methods to do HashMap Reverse
HashMap | reverseHashMap(HashMap map) reverse Hash Map HashMap<B, A> reverseMap = new HashMap<B, A>(); for (A a : map.keySet()) { B b = map.get(a); reverseMap.put(b, a); return reverseMap; |
Map | reverseHashMap(Map extends T, ? extends U> map) reverse Hash Map Map<U, T> ret = new HashMap<>(map.size()); for (Entry<? extends T, ? extends U> entr : map.entrySet()) { ret.put(entr.getValue(), entr.getKey()); return ret; |