8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Configuration MACRO ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
18 module ALib.Strings.Search;
19 import ALib.Characters.Functions;
27template<
typename TChar, lang::Case TSensitivity>
30template<
typename TChar, lang::Case TSensitivity>
53 if (needleIdx ==
needle.Length())
62template<
typename TChar, lang::Case TSensitivity>
67 if ( haystackIdx < 0 ) haystackIdx= 0;
68 if ( haystackIdx +
needle.Length() > haystack.
Length() )
return -1;
74 while (haystackIdx != haystack.
Length()) {
76 needle .Buffer()[needleIdx] ) )
80 if ( needleIdx >=
needle.Length() )
81 return (haystackIdx - needleIdx);
constexpr integer Length() const
constexpr const TChar * Buffer() const
constexpr bool IsNull() const
~TStringSearch()
Destructor.
TStringSearch(const TString< TChar > &pNeedle=nullptr)
TAString< TChar, lang::HeapAllocator > needle
The needle set Knuth-Morris-Pratt prefix length table.
integer kmpTableLength
Length of #"kmpTable".
void Compile(const TString< TChar > &needle)
integer Search(const TString< TChar > &haystack, integer startIdx=0)
integer * kmpTable
The Knuth-Morris-Pratt prefix length table.
bool Equal(TChar lhs, TRhs rhs)
lang::integer integer
Type alias in namespace alib.