Skip to content

Instantly share code, notes, and snippets.

@shangoyanyi
Created March 29, 2016 03:20
Show Gist options
  • Save shangoyanyi/eb68d2dad701a40b770b to your computer and use it in GitHub Desktop.
Save shangoyanyi/eb68d2dad701a40b770b to your computer and use it in GitHub Desktop.
public static <T, E> Set<T> getKeysByValue(Map<T, E> map, E value) {
Set<T> keys = new HashSet<T>();
for (Entry<T, E> entry : map.entrySet()) {
if (entry.getValue().equals(value)) {
keys.add(entry.getKey());
}
}
return keys;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment