Commit 5b0c6da1 authored by jkvis's avatar jkvis

More childtab examples

parent e1824607
......@@ -33,6 +33,8 @@ int GESA_create(GESA* const gesa,
for (size_t i = 0; i < length; ++i)
{
gesa->sa[i] = 0;
gesa->lcp[i] = 0;
gesa->da[i] = 0;
} // for
return sais((GESA_char_t*) string, gesa->sa, gesa->lcp, (int) length);
......
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../include/gesa.h"
#include "utils.h"
......@@ -17,19 +18,28 @@ int main(int argc, char* argv[])
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_index_t* childtab = malloc(21 * sizeof(*childtab));
GESA_index_t* childtab = malloc(length * sizeof(*childtab));
assert(childtab != 0);
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]);
} // for
free(childtab);
GESA_destroy(&gesa, GESA_KEEP_STRINGS);
return EXIT_SUCCESS;
} // 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