Normalizes the specified input and returns its distinct tokens. Optimized for small number of tokens. @param token token @return distinct tokens
(final byte[] token)
| 1066 | * @return distinct tokens |
| 1067 | */ |
| 1068 | public static byte[][] distinctTokens(final byte[] token) { |
| 1069 | final byte[][] tokens = split(normalize(token), ' '); |
| 1070 | int tl = tokens.length; |
| 1071 | for(int i = 0; i < tl - 1; i++) { |
| 1072 | for(int j = i + 1; j < tl; j++) { |
| 1073 | if(eq(tokens[i], tokens[j])) { |
| 1074 | Array.remove(tokens, j, 1, tl); |
| 1075 | j--; tl--; |
| 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | return Array.copyOf(tokens, tl); |
| 1080 | } |
| 1081 | |
| 1082 | /** |
| 1083 | * Checks if the specified token has only whitespace. |