Created
September 5, 2019 20:20
-
-
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.
This file contains hidden or 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
/** | |
* 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