Created
October 23, 2018 09:05
-
-
Save lovasoa/65460dc69073e3cce56e2aa2ac40d768 to your computer and use it in GitHub Desktop.
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
private static PrimitiveIterator.OfInt alphaChars(CharSequence s) { | |
return s.chars().filter(Character::isAlphabetic).map(Character::toLowerCase).iterator(); | |
} | |
public static boolean compareAlphabeticCharacters(CharSequence a, CharSequence b) { | |
PrimitiveIterator.OfInt aStream = alphaChars(a); | |
PrimitiveIterator.OfInt bStream = alphaChars(b); | |
while (aStream.hasNext() && bStream.hasNext()) { | |
if (aStream.nextInt() != bStream.nextInt()) return false; | |
} | |
return !aStream.hasNext() && !bStream.hasNext(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment