8000 GitHub - dgoffredo/aho-corasick: playing with prefix tries
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dgoffredo/aho-corasick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#include <aho_corasick.h>

#include <iostream>

int main() {
  AhoCorasick::PrefixTrie dictionary;
  dictionary.insert("a");
  dictionary.insert("aa");
  dictionary.insert("aab");
  dictionary.insert("baa");
  dictionary.insert("baab");
  dictionary.insert("aac");
    
  AhoCorasick::Searcher searcher{std::move(dictionary)};
  const char text[] = "aabaaabaab";
  for (auto [it, end] = searcher.find_all(text); it != end; ++it) {
   std::cout << *it << ": found at offset " << (it->data() - text) << '\n';
  }
}
a: found at offset 0
aa: found at offset 0
a: found at offset 1
aab: found at offset 0
a: found at offset 3
baa: found at offset 2
aa: found at offset 3
a: found at offset 4
aa: found at offset 4
a: found at offset 5
aab: found at offset 4
a: found at offset 7
baa: found at offset 6
aa: found at offset 7
a: found at offset 8
baab: found at offset 6
aab: found at offset 7

The searcher examines each character at most once.

About

playing with prefix tries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0