Created
January 8, 2019 02:51
-
-
Save lordk911/35f854ae4a74aa96176c4e5faa751980 to your computer and use it in GitHub Desktop.
map key value 换位
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private <T> Map<T,T> filp(Map<T,T> m) { | |
Set<T> keys = m.keySet(); | |
Map<T,T> m2 = new HashMap<T,T>(); | |
for (T key : keys) { | |
T value = m.get(key); | |
m2.put(value, key); | |
} | |
return m2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment