Class KMPByteIndexer
java.lang.Object
cool.scx.io.indexer.KMPByteIndexer
- All Implemented Interfaces:
ByteIndexer
KMPByteIndexer
- Version:
- 0.0.1
- Author:
- scx567888
-
Field Summary
Fields inherited from interface ByteIndexer
NO_MATCH -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
KMPByteIndexer
public KMPByteIndexer(byte[] pattern)
-
-
Method Details
-
buildLPS
public static int[] buildLPS(byte[] pattern) -
indexOf
Description copied from interface:ByteIndexer支持跨 chunk 的回溯匹配, 因此返回值可能为负数 若未匹配到 请返回 NO_MATCH 可以不处理 空匹配模式 的边界情况 (上层会根据 isEmptyPattern 直接走快速路径), 但要保证 isEmptyPattern 实现正确- Specified by:
indexOfin interfaceByteIndexer- Parameters:
chunk- chunk- Returns:
- 匹配的索引位置
-
isEmptyPattern
public boolean isEmptyPattern()Description copied from interface:ByteIndexer是否为空匹配模式- Specified by:
isEmptyPatternin interfaceByteIndexer
-
pattern
public byte[] pattern() -
matchedLength
public int matchedLength()当前已匹配的模式串长度 -
reset
public void reset()
-