Skip to content

santazhang/mruby-kmp

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

KMP searching algorithm in mruby

Using with mruby

Make a local copy of the mruby git tree, add the gem in your build_config.rb:

conf.gem :github => 'santazhang/mruby-kmp', :branch => 'master'

And then just build mruby with rake.

Usage

kmp = KMP.new 'needle'
p kmp.match_first('finding a needle in a haystack')
# => 10

kmp = KMP.new [1, 2, 3]
p kmp.match_all([0, 1, 2, 3, 1, 2, 3])
# => [1, 4]

kmp = KMP.new 'rr'
p kmp.match_all('rrrr')
# => [0, 1, 2]
p kmp.match_all('rrrr', overlap=false)
# => [0, 2]

About

KMP searching algorithm in mruby

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages