5 #include <libutl/Object.h> 30 template <
class T =
char>
46 set(owner, pat, patLen);
55 const T* find(
const T* str,
size_t strLen)
const;
63 void set(
bool owner,
const T* pat,
size_t patLen);
76 return getFlag(flg_owner);
83 setFlag(flg_owner, owner);
97 if (isOwner())
delete[] _pat;
116 size_t patLen = _patLen;
120 const T* strPtr = str + patLen - 1;
121 const T* strEnd = str + strLen;
122 while (strPtr < strEnd)
124 const T* patPtr = pat + patLen - 1;
125 while (*patPtr == *strPtr)
127 if (patPtr == pat)
return strPtr;
144 if (isOwner())
delete[] _pat;
153 for (i = 0; i < A; i++)
157 for (i = 0; i < patLen; i++)
159 skip[(
uint64_t)pat[i]] = patLen - 1 - i;
182 boyerMooreSearch(
const T* str,
size_t strLen,
const T* pat,
size_t patLen)
#define UTL_CLASS_IMPL_TPL(className, T)
Implementation of standard UTL++ functionality for a template class.
void deInit()
De-initialize UTL++.
const T & max(const T &a, const T &b, const R &... args)
Return the largest value among two or more provided values of the same type.
bool isOwner() const
Get the owner flag.
Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.
unsigned long uint64_t
Unsigned 64-bit integer.
Boyer-Moore string search.
void setOwner(bool owner)
Get the owner flag.
unsigned int uint_t
Unsigned integer.
const uint_t uint_t_max
Maximum uint_t value.
unsigned short ushort_t
Unsigned short integer.
const T & min(const T &a, const T &b, const R &... args)
Return the smallest value among two or more provided values of the same type.
#define UTL_CLASS_DECL_TPL(DC, T, BC)
Declaration of standard UTL++ functionality for a template class with one parameter.
size_t length() const
Get the length of the pattern.
Root of UTL++ class hierarchy.
void init()
Initialize UTL++.
BoyerMooreSearch(bool owner, const T *pat, size_t patLen, uint_t A=uint_t_max)
Constructor.