Class KMPDataIndexer

java.lang.Object
cool.scx.io.KMPDataIndexer
All Implemented Interfaces:
DataIndexer

public class KMPDataIndexer extends Object implements DataIndexer
  • Constructor Summary

    Constructors
    Constructor
    Description
    KMPDataIndexer(byte[] pattern)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    computeLPSArray(byte[] pattern)
     
    int
    indexOf(byte[] bytes, int position, int length)
    如果 没找到返回 -1 否则返回索引位置 此方法会循环调用 所以注意内部处理 建议每次都重新创建

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KMPDataIndexer

      public KMPDataIndexer(byte[] pattern)
  • Method Details

    • computeLPSArray

      public static int[] computeLPSArray(byte[] pattern)
    • indexOf

      public int indexOf(byte[] bytes, int position, int length)
      Description copied from interface: DataIndexer
      如果 没找到返回 -1 否则返回索引位置 此方法会循环调用 所以注意内部处理 建议每次都重新创建
      Specified by:
      indexOf in interface DataIndexer
      Parameters:
      bytes - bytes
      position - position
      length - length
      Returns:
      l