Skip to content

Instantly share code, notes, and snippets.

@lordk911
Created January 8, 2019 02:51
Show Gist options
  • Save lordk911/35f854ae4a74aa96176c4e5faa751980 to your computer and use it in GitHub Desktop.
Save lordk911/35f854ae4a74aa96176c4e5faa751980 to your computer and use it in GitHub Desktop.
map key value 换位
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