gesa.h 1.44 KB
Newer Older
jkvis's avatar
jkvis committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#if !defined(__gesa_h__)
#define __gesa_h__


#include <stddef.h>
#include <stdio.h>


#if defined(__cplusplus)
extern "C"
{
#endif


typedef unsigned char GESA_char_t;   // base type for strings
typedef int           GESA_index_t;  // base type for indices (signed)


static int const GESA_KEEP_STRINGS    = 0;
static int const GESA_DESTROY_STRINGS = 1;


typedef struct
{
    size_t              n;       // the number of 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              total;   // the total length of the suffix array
    GESA_index_t*       sa;      // the suffix array
    GESA_index_t*       lcp;     // the longest common prefix array
    GESA_index_t*       da;      // the document array: which suffix comes
                                 // from which string
} GESA; // GESA


// Creates a GESA from a single string
// On success it returns 0
int GESA_create(GESA* const              gesa,
                GESA_char_t const* const string,
                size_t const             length);


// All created GESAs should be destroyed. Normally, the GESA does not
// have ownership of the strings. In case it does (e.g., creation via
// deserialization) supply the GESA_DESTROY_STRINGS flag.
void GESA_destroy(GESA* const gesa,
                  int const   destroy_strings);


#if defined(__cplusplus)
jkvis's avatar
jkvis committed
51
} // extern "C"
jkvis's avatar
jkvis committed
52 53 54
#endif

#endif