ref[move]: move hash to net package

This commit is contained in:
godotg
2023-09-02 19:17:15 +08:00
parent 00bb1e37a0
commit e158e92497
6 changed files with 4 additions and 105 deletions
@@ -22,7 +22,7 @@ import com.zfoo.protocol.collection.CollectionUtils;
import com.zfoo.protocol.exception.RunException;
import com.zfoo.protocol.model.Pair;
import com.zfoo.protocol.registration.ProtocolModule;
import com.zfoo.util.math.ConsistentHash;
import com.zfoo.net.util.ConsistentHash;
import org.springframework.lang.Nullable;
import java.util.TreeMap;
@@ -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;
package com.zfoo.net.util;
import com.zfoo.protocol.model.Pair;
@@ -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;
package com.zfoo.net.util;
/**
* 改进的hash算法虽然发布比较均匀但是没有Java自带的hash算法速度快所以需要知道自己需要什么
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.util.math;
package com.zfoo.net.util;
import com.zfoo.protocol.model.Pair;
import com.zfoo.protocol.util.JsonUtils;
@@ -1,55 +0,0 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.util.math;
/**
* @author godotg
* @version 3.0
*/
public class Combinatorics {// |kɒmbinəˋtɒ:riks|n.组合学
//输出数组a的startIndex~endIndex(包括端点)的全排列
public void permutation(int[] a, int startIndex, int endIndex) {
if (startIndex == endIndex) {
for (int i = 0; i <= endIndex; i++) {
System.out.print(a[i]);
}
System.out.println();
}
for (int i = startIndex; i <= endIndex; i++) {
swap(a, i, startIndex);
permutation(a, startIndex + 1, endIndex);
swap(a, i, startIndex);
}
}
//输出数组a的全排列
public void permutation(int[] a) {
permutation(a, 0, a.length - 1);
}
//public void Combination(int[] a,int[] b,int)
//交换数组中的两个元素
public void swap(int[] a, int xIndex, int yIndex) {
int temp = a[xIndex];
a[xIndex] = a[yIndex];
a[yIndex] = temp;
}
}
@@ -1,44 +0,0 @@
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.util.math.dfa;
import org.junit.Ignore;
import org.junit.Test;
import java.util.List;
/**
* @author godotg
* @version 3.0
*/
@Ignore
public class WordTreeTest {
@Test
public void test() {
WordTree tree = new WordTree();
tree.addWord("");
tree.addWord("大土豆");
tree.addWord("土豆");
tree.addWord("刚出锅");
tree.addWord("出锅");
tree.addWord("fuck");
// 正文
String text = "text asdff asdf afucksdf ";
List<String> matchAll = tree.matchAll(text, -1, true, false);
System.out.println(matchAll);
}
}