Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size_t find(const String& sub) const {
- if (size < sub.size) return size;
- auto p = str;
- auto pend = p + size - sub.size;
- auto psubend = sub.str + sub.size;
- while(p < pend)
- {
- auto pitem = p;
- auto psubitem = sub.str;
- while(pitem < psubend)
- {
- if(*pitem != *psubitem)
- {
- goto next;
- }
- pitem++;
- psubitem++;
- }
- return p - str;
- next:
- p++;
- }
- return size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement