|
ADS
Algorithms and Data Structures
|
The exact string matching, beyond the book: the occurrences of a pattern \( P \) of \( m \) characters in a text \( T \) of \( n \) characters, i.e., the places \( s \in [ 0 , n - m ] \) with \( T[ s .. s + m - 1 ] = P \). More...
#include <cstddef>#include <cstdint>#include "ADS/Contract.h"#include <string_view>#include <vector>#include "ADS/string/impl/StringMatching.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| std::vector< std::size_t > | ADS::naiveMatching (std::string_view T, std::string_view P) |
| the places of all the occurrences of \( P \) in \( T \), by trying every shift | |
| std::vector< long > | ADS::failure (std::string_view P) |
| the failure function: \( F[ q ] \) is the length of the longest proper border of \( P[ 0 .. q - 1 ] \), and \( F[ 0 ] = -1 \) | |
| std::vector< std::size_t > | ADS::kmp (std::string_view T, std::string_view P, long *comparisons=nullptr) |
| the places of all the occurrences of \( P \) in \( T \), by Knuth-Morris-Pratt; the comparisons of characters go to *comparisons, if given | |
| std::vector< long > | ADS::strongFailure (std::string_view P) |
| the strong failure function: \( G[ q ] = F[ q ] \) unless \( P[ F[ q ] ] = P[ q ] \), in which case \( G[ q ] = G[ F[ q ] ] \); \( G[ m ] = F[ m ] \) | |
| std::vector< std::size_t > | ADS::kmpStrong (std::string_view T, std::string_view P, long *comparisons=nullptr) |
| the occurrences of kmp() above, with the strong failure function on a mismatch | |
| std::vector< std::size_t > | ADS::boyerMoore (std::string_view T, std::string_view P, long *comparisons=nullptr) |
| the places of all the occurrences of \( P \) in \( T \), by Boyer-Moore with the bad character and the strong good suffix rules | |
| std::vector< std::size_t > | ADS::horspool (std::string_view T, std::string_view P, long *comparisons=nullptr) |
| the places of all the occurrences of \( P \) in \( T \), by Horspool | |
| std::vector< std::size_t > | ADS::shiftOr (std::string_view T, std::string_view P) |
| the places of all the occurrences of \( P \) in \( T \), by Shift-Or | |
| std::vector< std::size_t > | ADS::zFunction (std::string_view S) |
| the Z-function: \( Z[ i ] \) is the length of the longest common prefix of \( S \) and \( S[ i .. ] \), and \( Z[ 0 ] = |S| \) | |
| std::vector< std::size_t > | ADS::zMatching (std::string_view T, std::string_view P) |
| the places of all the occurrences of \( P \) in \( T \), by the Z-function of \( P \) and the Z-boxes of \( T \) | |
| std::vector< std::size_t > | ADS::twoWay (std::string_view T, std::string_view P) |
| the places of all the occurrences of \( P \) in \( T \), by the Two-Way algorithm of Crochemore and Perrin | |
The exact string matching, beyond the book: the occurrences of a pattern \( P \) of \( m \) characters in a text \( T \) of \( n \) characters, i.e., the places \( s \in [ 0 , n - m ] \) with \( T[ s .. s + m - 1 ] = P \).
These are the algorithms of the textbooks, which count their comparisons of characters where asked; the engineered search of ADS is StringSearcher [see StringSearch.h].
The empty pattern occurs at every place \( 0 , \ldots , n \).
The contracts [see Contract.h]: the failure function gives proper borders, the Z-function values that fit the string, and every search the occurrences of naiveMatching() (checked at the level of the audits). The operations are defined in StringMatching.tpp.