ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
StringSearch.h

The exact search of a pattern \( P \) of \( m \) bytes in a text \( T \) of \( n \) bytes, beyond the book. More...

Files

file  ADS/string/StringSearch.h
 The exact search of a pattern \( P \) of \( m \) bytes in a text \( T \) of \( n \) bytes, beyond the book: the engineered search of ADS, the one that the benchmark of the searches compares with memmem() of the C library, std::search() with its three searchers and the searchers of Boost.Algorithm, while kmp() [see StringMatching.h] stays the algorithm of the textbook.

Classes

class  ADS::StringSearcher
 a pattern prepared for the search of its occurrences in any text More...

Macros

#define ADS_SEARCH_SIMD   ADS_SIMD
 the vector comparisons of the filter: 1 by the vectors of Highway, 32 bytes at a time, at the instructions of the compiler [see SimdInline.h], 0 none (memchr() and bytes); by default ADS_SIMD [see Simd.h], and the same in all the translation units of a program

Functions

std::size_t ADS::findFirst (std::string_view T, std::string_view P, std::size_t from=0)
 the first occurrence of \( P \) in \( T \) at or after from, npos if none, by a StringSearcher used once
std::vector< std::size_t > ADS::findAll (std::string_view T, std::string_view P)
 all the occurrences of \( P \) in \( T \), overlapping ones included, by a StringSearcher used once

Detailed description

The exact search of a pattern \( P \) of \( m \) bytes in a text \( T \) of \( n \) bytes, beyond the book.

The definitions, the invariants and the costs of the area are in Theory of strings.

Macro definition documentation

◆ ADS_SEARCH_SIMD

#define ADS_SEARCH_SIMD   ADS_SIMD

the vector comparisons of the filter: 1 by the vectors of Highway, 32 bytes at a time, at the instructions of the compiler [see SimdInline.h], 0 none (memchr() and bytes); by default ADS_SIMD [see Simd.h], and the same in all the translation units of a program

Function documentation

◆ findAll()

std::vector< std::size_t > ADS::findAll ( std::string_view T,
std::string_view P )
inlinenodiscard

all the occurrences of \( P \) in \( T \), overlapping ones included, by a StringSearcher used once

◆ findFirst()

std::size_t ADS::findFirst ( std::string_view T,
std::string_view P,
std::size_t from = 0 )
inlinenodiscard

the first occurrence of \( P \) in \( T \) at or after from, npos if none, by a StringSearcher used once