Sunday algorithm for string search
public class SUNDAY {public SUNDAY () {///TODO: Add constructor logic//} public int Qfind here
CHR (String str, string sfind) {int str_length = 0;
int fin_length = 0;
int find_count = 0;
int start = 0;
int movenum = 0; if (str.
Length < Sfind.length) {return find_count; } str_length = str.
Length;
Fin_length = Sfind.length;
while (start + fin_length <= str_length) {movenum++; BOOL Isfind = false;//whether string s_temp = str was found in this move.
Substring (start, fin_length);
if (s_temp = = Sfind) {find_count++; start = start + fin_length; isfind = true;}
if (Isfind = false)//if not found compute next move position {int forwardpos = Qfindpos (str, sfind, start, fin_length);
start = Forwardpos;
} return Find_count; //Find the character in the string (not the last character) position (reciprocal)/not found return fin_length, find the return position/**////<summary>///Find the position (reciprocal) of the character in the string (not counting the last character); return str.length, find return position///</summary>///<param name= "str" >< /param>///<param name= "Find" ></param>///<param name= "pos" ></param>///<para M name= "Fin_length" ></param>///<returns></returns> public int qfindpos (string str, string f IND, int pos, int fin_length) {int returnpos = str.
Length; char[] SCHR = str.
ToCharArray (); char[] Sfin = find.
ToCharArray (); if (pos + fin_length) < Str.
Length) {Char chrfind = schr[pos + fin_length];//The character to be found if (fin_length >= 1) { if (find. LastIndexOf (Chrfind) >-1) {Returnpos = pos + fin_length-find.
LastIndexOf (Chrfind);
else {Returnpos = pos + fin_length + 1;
}} return returnpos; }
}