public class MultiStrFinder extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
MultiStrFinder.Node
AC 自动机节点
|
Modifier and Type | Field and Description |
---|---|
protected int |
allCharSize |
protected Map<Character,Integer> |
charIndexMap |
protected MultiStrFinder.Node |
root |
Constructor and Description |
---|
MultiStrFinder(Collection<String> source)
构建多字符串查询器
|
Modifier and Type | Method and Description |
---|---|
protected void |
buildFail()
构建 fail指针过程
构建 directRouter 直接访问路由表 减少跳fail次数 直接跳 router 边
|
protected void |
buildPrefixTree(Collection<String> stringSst)
构建前缀树
|
Map<String,List<Integer>> |
findMatch(String text)
查询匹配的字符串
|
protected int |
getIndex(char c)
获取字符 下标
|
static MultiStrFinder |
of(Collection<String> source)
创建多字符串查询器
|
protected final int allCharSize
protected final MultiStrFinder.Node root
public MultiStrFinder(Collection<String> source)
source
- 字符串集合public static MultiStrFinder of(Collection<String> source)
source
- 字符串集合protected void buildPrefixTree(Collection<String> stringSst)
stringSst
- 待匹配的字符串protected void buildFail()
public Map<String,List<Integer>> findMatch(String text)
text
- 返回每个匹配的 字符串 value是字符首字母地址protected int getIndex(char c)
c
- 字符Copyright © 2025. All rights reserved.