diff --git a/util/src/main/java/com/zfoo/util/math/dfa/WordTree.java b/protocol/src/main/java/com/zfoo/protocol/collection/tree/DfaWordTree.java
similarity index 95%
rename from util/src/main/java/com/zfoo/util/math/dfa/WordTree.java
rename to protocol/src/main/java/com/zfoo/protocol/collection/tree/DfaWordTree.java
index 874532b9..941d15ae 100644
--- a/util/src/main/java/com/zfoo/util/math/dfa/WordTree.java
+++ b/protocol/src/main/java/com/zfoo/protocol/collection/tree/DfaWordTree.java
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
- *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
-package com.zfoo.util.math.dfa;
+package com.zfoo.protocol.collection.tree;
import com.zfoo.protocol.collection.CollectionUtils;
@@ -32,7 +31,7 @@ import java.util.*;
*
巾
* 其中每个节点都是一个WordTree对象,查找时从上向下查找。
*/
-public class WordTree extends HashMap {
+public class DfaWordTree extends HashMap {
/**
@@ -44,7 +43,7 @@ public class WordTree extends HashMap {
/**
* 默认构造
*/
- public WordTree() {
+ public DfaWordTree() {
}
@@ -66,9 +65,9 @@ public class WordTree extends HashMap {
* @param word 单词
*/
public void addWord(String word) {
- WordTree parent = null;
- WordTree current = this;
- WordTree child;
+ DfaWordTree parent = null;
+ DfaWordTree current = this;
+ DfaWordTree child;
char currentChar = 0;
int length = word.length();
for (var i = 0; i < length; i++) {
@@ -78,7 +77,7 @@ public class WordTree extends HashMap {
child = current.get(currentChar);
if (child == null) {
// 无子类,新建一个子节点后存放下一个字符
- child = new WordTree();
+ child = new DfaWordTree();
current.put(currentChar, child);
}
parent = current;
@@ -147,7 +146,7 @@ public class WordTree extends HashMap {
}
var findWords = new ArrayList();
- WordTree current = this;
+ DfaWordTree current = this;
int length = text.length();
// 存放查找到的字符缓存。完整出现一个词时加到findedWords中,否则清空
StringBuilder wordBuffer;
diff --git a/util/src/test/java/com/zfoo/util/collection/GeneralTreeTest.java b/protocol/src/test/java/com/zfoo/protocol/collection/GeneralTreeTest.java
similarity index 96%
rename from util/src/test/java/com/zfoo/util/collection/GeneralTreeTest.java
rename to protocol/src/test/java/com/zfoo/protocol/collection/GeneralTreeTest.java
index e9c43eb1..9cdbc2f4 100644
--- a/util/src/test/java/com/zfoo/util/collection/GeneralTreeTest.java
+++ b/protocol/src/test/java/com/zfoo/protocol/collection/GeneralTreeTest.java
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
- *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
-package com.zfoo.util.collection;
+package com.zfoo.protocol.collection;
import com.zfoo.protocol.collection.tree.GeneralTree;
import org.junit.Test;
diff --git a/util/src/test/java/com/zfoo/util/collection/CollectionUtilsTest.java b/protocol/src/test/java/com/zfoo/protocol/util/CollectionUtilsTest.java
similarity index 98%
rename from util/src/test/java/com/zfoo/util/collection/CollectionUtilsTest.java
rename to protocol/src/test/java/com/zfoo/protocol/util/CollectionUtilsTest.java
index 3d67509b..5f38aacb 100644
--- a/util/src/test/java/com/zfoo/util/collection/CollectionUtilsTest.java
+++ b/protocol/src/test/java/com/zfoo/protocol/util/CollectionUtilsTest.java
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
- *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
-package com.zfoo.util.collection;
+package com.zfoo.protocol.util;
import com.zfoo.protocol.collection.CollectionUtils;
import com.zfoo.protocol.model.Pair;