SHARE
TWEET

Untitled

a guest Apr 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. size_t goLeft(size_t a, size_t b, const string& pattern, const string& text,
  2.               const SuffixArray& suffixArr, size_t prev) {
  3.   if (a > b) return prev;
  4.   size_t mid = (a + b)/2;
  5.   if (!equalityCheck(pattern, text.substr(suffixArr[mid]))) {
  6.     return goLeft(mid+1, b, pattern, text, suffixArr, prev);
  7.   }
  8.   return goLeft(0, mid-1, pattern, text, suffixArr, mid);
  9. }
  10.  
  11. size_t goRight(size_t a, size_t b, const string& pattern, const string& text,
  12.               const SuffixArray& suffixArr, size_t prev) {
  13.   if (a > b) return prev;
  14.   size_t mid = (a + b)/2;
  15.   if (!equalityCheck(pattern, text.substr(suffixArr[mid]))) {
  16.     return goRight(0, mid-1, pattern, text, suffixArr, prev);
  17.   }
  18.   return goRight(mid+1, b, pattern, text, suffixArr, mid);
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top