Class AhoCorasick

Class Documentation

class AhoCorasick

the automaton of Aho and Corasick of a set of patterns

Public Functions

AhoCorasick(void)

no pattern

explicit AhoCorasick(const std::vector<std::string> &P)

the patterns P, numbered 0 , 1 , … in their order, built

Pre:

no pattern is empty

std::size_t add(std::string_view P)

adds the pattern P, the automaton to be built again; its number

Pre:

P is not empty

void build(void)

the failures, the transitions and the output links, \( O( 256 M ) \)

std::vector<std::pair<std::size_t, std::size_t>> findAll(std::string_view T) const

the occurrences ( start , number ) of the patterns in T, by increasing end, the longer pattern first for one end

Pre:

built

Post:

the occurrences of naiveMatching() for each pattern (an audit)

std::size_t count(std::string_view T) const

the number of the occurrences of the patterns in T

Pre:

built

template<class F>
inline void forEach(std::string_view T, F &&report) const

each occurrence ( start , number ) of the patterns in T given to report(), by increasing end, the longer pattern first for one end

Pre:

built

inline std::size_t size(void) const

the number of patterns

inline std::size_t states(void) const

the number of states, the nodes of the trie