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"
27template<
typename TChar, lang::Case TSensitivity>
30template<
typename TChar, lang::Case TSensitivity>
57 if (needleIdx ==
needle.Length())
63 kmpTable[needleIdx]= pfxLen;
66template<
typename TChar, lang::Case TSensitivity>
71 if ( haystackIdx < 0 ) haystackIdx= 0;
72 if ( haystackIdx +
needle.Length() > haystack.
Length() )
return -1;
78 while (haystackIdx != haystack.
Length())
81 needle .Buffer()[needleIdx] ) )
85 if ( needleIdx >=
needle.Length() )
86 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.