Java Map Reverse reverseMap(Map map)

Here you can find the source of reverseMap(Map map)

Description

reverse Map

License

Apache License

Declaration

public static <K, V> Map<V, K> reverseMap(Map<K, V> map) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    public static <K, V> Map<V, K> reverseMap(Map<K, V> map) {
        Map<V, K> ret = new HashMap<V, K>();
        for (K key : map.keySet()) {
            ret.put(map.get(key), key);//  w ww.  j  a va2s  . co m
        }
        return ret;
    }

    public static <S, T> T get(Map<S, T> m, S key, T def) {
        T ret = m.get(key);
        if (ret == null) {
            ret = def;
        }
        return ret;
    }
}

Related

  1. reverseKeyAndValue(Map map)
  2. reverseLabelMap(Map labelMap)
  3. reverseMap(List listSeq)
  4. reverseMap(Map map)
  5. reverseMap(Map map)
  6. reverseMap(Map map)
  7. reverseMap(Map map)
  8. reverseMap(Map origMap)
  9. reverseMap(Map map)