Class KMPByteIndexer
java.lang.Object
cool.scx.io.indexer.KMPByteIndexer
- All Implemented Interfaces:
ByteIndexer
KMPByteIndexer
- Version:
- 0.0.1
- Author:
- scx567888
-
Constructor Details
-
KMPByteIndexer
public KMPByteIndexer(byte[] pattern)
-
-
Method Details
-
buildLPS
public static int[] buildLPS(byte[] pattern) -
indexOf
Description copied from interface:ByteIndexer- 匹配成功需重置状态, 以便能够直接进行下次匹配.
- 可以不处理 空匹配模式 的边界情况 (上层会根据 patternLength == 0 直接走快速路径), 但要保证 patternLength 实现正确.
- Specified by:
indexOfin interfaceByteIndexer
-
isEmptyPattern
public boolean isEmptyPattern()Description copied from interface:ByteIndexer是否为空匹配模式
- 对于固定长度模式串: 返回 是否是空模式串
- 对于无法静态确定的可变长度模式串 (如正则), 返回 false.
- Specified by:
isEmptyPatternin interfaceByteIndexer
-
reset
public void reset()Description copied from interface:ByteIndexer重置匹配状态- Specified by:
resetin interfaceByteIndexer
-