Exemple #1
0
int main (int argc, char *argv[])
{
  if (argc != 3) {
    printf("Really? Even in test?\n");
    return 1;
  }

  mmuInit();
  tString text = strCreate(argv[1]);
  tString search = strCreate(argv[2]);

  printf("Text: %s\n"
         "Text len: %u\n", text.data, text.len);
  printf("Hledany string: %s\n"
         "Hledany len: %u\n", search.data, search.len);
  int position = kmpSearch(text, search);
  printf("Pozice je: %d\n", position);

  strFree(&text);
  strFree(&search);

  mmuGlobalFree();

  return 0;
}
Exemple #2
0
int main(){
    strcpy(T, "asdhasdhejasdasdhejasdasd");
    strcpy(P, "hej");
    
    n = 25; m = 3;

    kmpPreprocess();
    kmpSearch();

    return 0;
}
Exemple #3
0
/* Returns the number of occurances of the pattern in the text. */
size_t subSearch(char* text, const char* pattern) {
    size_t occurances = 0;
    char* temp = text;
    size_t index = 0;
    
    while ((index = kmpSearch(temp, pattern)) != strlen(temp)) {
        occurances += 1;
        if (strlen(pattern) + index >= strlen(temp)) {
            break;
        } else {
            temp += strlen(pattern) + index;
        }
    }
    return occurances;
}
Exemple #4
0
/**
 * @info      Fce hleda podretezec v retezci
 * @param   tSymbolData - retezce, v prvnim se hleda, druhy se hleda v prvnim
 * @return  tSymbolData - vrati pozici v prvnim stringu, na ktere nasel druhy string
 */
void find (tSymbolData *dest, tSymbolData *text, tSymbolData *searched)
{
  if (text == NULL || searched == NULL) return;
  dest->type = DT_NUMBER;
  dest->data.dData = (double) kmpSearch(text->data.sData, searched->data.sData);
}