Skip to content

Instantly share code, notes, and snippets.

@basilwong
Created September 5, 2019 20:20
Show Gist options
  • Save basilwong/080611e4339d55dec41355a9a7cd15c5 to your computer and use it in GitHub Desktop.
Save basilwong/080611e4339d55dec41355a9a7cd15c5 to your computer and use it in GitHub Desktop.
Checks if all the lists representing the values of a hashmap are the same length.
/**
* Checks if all the lists representing the values of a hashmap are the same length.
* @param occurrenceFields a hashmap with strings as the keys and lists of strings as the values
* @return true if all the lists are the same length, false otherwise
*/
private static boolean checkLengths(HashMap<String, HashMap<String, String>> occurrenceFields) {
Set<Integer> sizes = new HashSet<Integer>();
for (HashMap<String, String> list : occurrenceFields.values()) {
sizes.add(list.size());
}
return sizes.size() == 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment