Created
August 13, 2015 17:15
-
-
Save trishagee/953ce7315c05a07496e8 to your computer and use it in GitHub Desktop.
This file contains 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
static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
IntStream stream = IntStream.range(0, LIST_SIZE); | |
if (parallel) { | |
stream = stream.parallel(); // Convert the stream to a parallel one | |
} | |
stream.forEach(i -> { | |
for (int j = 0; j < LIST_SIZE; j++) { | |
distances[i][j] = lev(wordList.get(i), wordList.get(j)); | |
} | |
}); | |
return distances; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment