Commit 3dcf8dc5 authored by jkvis's avatar jkvis

gesa library up to date with first version

parent a8ea503a
...@@ -22,14 +22,14 @@ static int const GESA_DESTROY_STRINGS = 1; ...@@ -22,14 +22,14 @@ static int const GESA_DESTROY_STRINGS = 1;
typedef struct typedef struct
{ {
size_t n; // the number of strings size_t n; // the number of strings
GESA_char_t const** string; // an array of n pointers to strings GESA_char_t const** string; // an array of n pointers to strings
size_t* length; // an array of the lengths of the strings size_t* length; // an array of the lengths of the strings
size_t total; // the total length of the suffix array size_t total; // the total length of the suffix array
GESA_index_t* sa; // the suffix array GESA_index_t* sa; // the suffix array
GESA_index_t* lcp; // the longest common prefix array GESA_index_t* lcp; // the longest common prefix array
GESA_index_t* da; // the document array: which suffix comes GESA_index_t* da; // the document array: which suffix comes
// from which string // from which string
} GESA; // GESA } GESA; // GESA
...@@ -39,13 +39,38 @@ int GESA_create(GESA* const gesa, ...@@ -39,13 +39,38 @@ int GESA_create(GESA* const gesa,
GESA_char_t const* const string, GESA_char_t const* const string,
size_t const length); size_t const length);
// All created GESAs should be destroyed. Normally, the GESA does not // All created GESAs should be destroyed. Normally, the GESA does not
// have ownership of the strings. In case it does (e.g., creation via // have ownership of the strings. In case it does (e.g., creation via
// deserialization) supply the GESA_DESTROY_STRINGS flag. // deserialization) supply the GESA_DESTROY_STRINGS flag.
void GESA_destroy(GESA* const gesa, void GESA_destroy(GESA* const gesa,
int const destroy_strings); int const destroy_strings);
// Merges two GESAs into one
// On success it returns 0
int GESA_merge(GESA* const gesa,
GESA const* const gesa_0,
GESA const* const gesa_1);
// WARNING: (de-)serialization is *NOT* portable across architectures
// Serializes a GESA including a copy of the strings
void GESA_serialize(GESA const* const gesa,
FILE* stream);
// Deserizalizes a GESA including newly allocated strings that should be
// freed explicitly, e.g., supply the GESA_DESTROY_STRINGS flag to the
// GESA_destroy function.
// On success it returns 0
int GESA_deserialize(GESA* const gesa,
FILE* stream);
// Calculates the longest common substring
GESA_index_t GESA_lcs(GESA_index_t* document,
GESA_index_t* index,
GESA const* const gesa);
// Prints a GESA for debug purposes
void GESA_print(GESA const* const gesa,
FILE* stream);
#if defined(__cplusplus) #if defined(__cplusplus)
} // extern "C" } // extern "C"
......
This diff is collapsed.
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