Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class SundaySearch2:public StringSearch
  2. {
  3. public:
  4. SundaySearch2(string T,string W):StringSearch(T,W) {}
  5. int Oracle[256];
  6.  
  7. void search()
  8. {
  9. for(int i=0; i<256; i++)
  10. {
  11. Oracle[i]=W.size()+1;
  12. }
  13.  
  14. for(int i=0; i<static_cast<int>(W.size()); i++)
  15. {
  16. Oracle[static_cast<int>(W[i])]=static_cast<int>(W.size())-i;
  17. }
  18. int i=0;
  19.  
  20.  
  21. while(i<=static_cast<int>(T.size())-static_cast<int>(W.size()))
  22. {
  23. if(matches_at(i))
  24. {
  25. cout <<"OD miejsca "<<i<<endl;
  26. v.push_back(i);
  27.  
  28. }
  29.  
  30. if(i+W.size()>=T.size())
  31. break;
  32. {
  33. i+=Oracle[static_cast<int>(T[i+W.size()])];
  34. // i+=Oracle[static_cast<int>(T[1+W.size()])];
  35. }
  36. }
  37.  
  38. }
  39. const vector<int>&getoccurences()
  40. {
  41.  
  42. return v;
  43. }
  44.  
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement