Sunday Algorithm for string search

Source: Internet
Author: User

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; }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.