mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package cn.hutool.dfa;
|
package cn.hutool.dfa;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.lang.Filter;
|
import cn.hutool.core.lang.Filter;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ public class WordTree extends HashMap<Character, WordTree> {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public WordTree addWords(String... words) {
|
public WordTree addWords(String... words) {
|
||||||
HashSet<String> wordsSet = CollectionUtil.newHashSet(words);
|
for (String word : CollUtil.newHashSet(words)) {
|
||||||
for (String word : wordsSet) {
|
|
||||||
addWord(word);
|
addWord(word);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -105,7 +103,7 @@ public class WordTree extends HashMap<Character, WordTree> {
|
|||||||
WordTree current = this;
|
WordTree current = this;
|
||||||
WordTree child;
|
WordTree child;
|
||||||
char currentChar = 0;
|
char currentChar = 0;
|
||||||
int length = word.length();
|
final int length = word.length();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
currentChar = word.charAt(i);
|
currentChar = word.charAt(i);
|
||||||
if (charFilter.accept(currentChar)) {//只处理合法字符
|
if (charFilter.accept(currentChar)) {//只处理合法字符
|
||||||
|
Reference in New Issue
Block a user