Commit 5b0c6da1 authored by jkvis's avatar jkvis

More childtab examples

parent e1824607
...@@ -33,7 +33,9 @@ int GESA_create(GESA* const gesa, ...@@ -33,7 +33,9 @@ int GESA_create(GESA* const gesa,
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
gesa->da[i] = 0; gesa->sa[i] = 0;
gesa->lcp[i] = 0;
gesa->da[i] = 0;
} // for } // for
return sais((GESA_char_t*) string, gesa->sa, gesa->lcp, (int) length); return sais((GESA_char_t*) string, gesa->sa, gesa->lcp, (int) length);
} // GESA_create } // GESA_create
......
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "../include/gesa.h" #include "../include/gesa.h"
#include "utils.h" #include "utils.h"
...@@ -17,19 +18,28 @@ int main(int argc, char* argv[]) ...@@ -17,19 +18,28 @@ int main(int argc, char* argv[])
GESA gesa; GESA gesa;
assert(GESA_create(&gesa, (GESA_char_t*) "accttacgacgaccttcca~", 21) == 0); //char const* const string = "accttacgacgaccttcca~";
char const* const string = "acaaacatat~";
size_t const length = strlen(string) + 1;
printf("%ld\n", length);
assert(GESA_create(&gesa, (GESA_char_t*) string, length) == 0);
GESA_print(&gesa, stdout); GESA_print(&gesa, stdout);
GESA_index_t* childtab = malloc(21 * sizeof(*childtab)); GESA_index_t* childtab = malloc(length * sizeof(*childtab));
assert(childtab != 0); assert(childtab != 0);
GESA_calculate_childtab(&gesa, childtab); GESA_calculate_childtab(&gesa, childtab);
for (size_t i = 0; i < 21; ++i) for (size_t i = 0; i < length - 1; ++i)
{ {
printf("%5ld %5d\n", i, childtab[i]); printf("%5ld %5d\n", i, childtab[i]);
} // for } // for
free(childtab);
GESA_destroy(&gesa, GESA_KEEP_STRINGS);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} // main } // main
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment