Code Monkey home page Code Monkey logo

strstrbykmp's Introduction

KMP算法实现的strstr接口

用KMP算法实现的strstr实现,基于纯C实现,方便使用。


usage

对外接口在"KMP.h"中提供

  • 如果只是简单的替换strstr函数
    那么直接使用kmp_strstr接口替换即可
  • 如果需要被搜索的字段在程序中是固定的
    可以使用kmp_strstr_dp接口来获得更好的性能
    PS: 该使用方式需要自己调用dp_constructdp_destroy接口维护dp数组的内存

how to test

# cd test/

# make
gcc main.c ../src/KMP.c -g -o runKMP

# ./runKMP  
kmp result1 = abcabcbbccc
strstr result1 = abcabcbbccc
kmp result2 = ccc
strstr result2 = ccc

reference

算法的具体实现参考了知乎大佬的算法详细介绍,详细说明可以看原贴:
知乎传送门

strstrbykmp's People

Contributors

wenda84 avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.