8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol 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>
59 kmpTable[needleIdx]= pfxLen;
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(const TString< TChar > &pNeedle=nullptr)
TAString< TChar, lang::HeapAllocator > needle
The needle set Knuth-Morris-Pratt prefix length table.
ALIB_DLL integer Search(const TString< TChar > &haystack, integer startIdx=0)
integer kmpTableLength
Length of kmpTable.
ALIB_DLL ~TStringSearch()
Destructor.
ALIB_DLL void Compile(const TString< TChar > &needle)
integer * kmpTable
The Knuth-Morris-Pratt prefix length table.
bool Equal(TChar lhs, TRhs rhs)
lang::integer integer
Type alias in namespace alib.