git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-support/gbcompress/zx0/libdivsufsort/divsufsort.h

      1 /*
      2  * divsufsort.h for libdivsufsort
      3  * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
      4  *
      5  * Permission is hereby granted, free of charge, to any person
      6  * obtaining a copy of this software and associated documentation
      7  * files (the "Software"), to deal in the Software without
      8  * restriction, including without limitation the rights to use,
      9  * copy, modify, merge, publish, distribute, sublicense, and/or sell
     10  * copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following
     12  * conditions:
     13  *
     14  * The above copyright notice and this permission notice shall be
     15  * included in all copies or substantial portions of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
     19  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
     21  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     22  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     24  * OTHER DEALINGS IN THE SOFTWARE.
     25  */
     26 
     27 #ifndef _DIVSUFSORT_H
     28 #define _DIVSUFSORT_H 1
     29 
     30 #ifdef __cplusplus
     31 extern "C" {
     32 #endif /* __cplusplus */
     33 
     34 #define DIVSUFSORT_API
     35 
     36 /*- Datatypes -*/
     37 #ifndef SAUCHAR_T
     38 #define SAUCHAR_T
     39 typedef unsigned char sauchar_t;
     40 #endif /* SAUCHAR_T */
     41 #ifndef SAINT_T
     42 #define SAINT_T
     43 typedef int saint_t;
     44 #endif /* SAINT_T */
     45 #ifndef SAIDX_T
     46 #define SAIDX_T
     47 typedef int saidx_t;
     48 #endif /* SAIDX_T */
     49 #ifndef PRIdSAIDX_T
     50 #define PRIdSAIDX_T "d"
     51 #endif
     52 
     53 /*- divsufsort context */
     54 typedef struct _divsufsort_ctx_t {
     55    saidx_t *bucket_A;
     56    saidx_t *bucket_B;
     57 } divsufsort_ctx_t;
     58 
     59 /*- Prototypes -*/
     60 
     61 /**
     62  * Initialize suffix array context
     63  *
     64  * @return 0 for success, or non-zero in case of an error
     65  */
     66 int divsufsort_init(divsufsort_ctx_t *ctx);
     67 
     68 /**
     69  * Destroy suffix array context
     70  *
     71  * @param ctx suffix array context to destroy
     72  */
     73 void divsufsort_destroy(divsufsort_ctx_t *ctx);
     74 
     75 /**
     76  * Constructs the suffix array of a given string.
     77  * @param ctx suffix array context
     78  * @param T[0..n-1] The input string.
     79  * @param SA[0..n-1] The output array of suffixes.
     80  * @param n The length of the given string.
     81  * @return 0 if no error occurred, -1 or -2 otherwise.
     82  */
     83 DIVSUFSORT_API
     84 saint_t divsufsort_build_array(divsufsort_ctx_t *ctx, const sauchar_t *T, saidx_t *SA, saidx_t n);
     85 
     86 #if 0
     87 /**
     88  * Constructs the burrows-wheeler transformed string of a given string.
     89  * @param T[0..n-1] The input string.
     90  * @param U[0..n-1] The output string. (can be T)
     91  * @param A[0..n-1] The temporary array. (can be NULL)
     92  * @param n The length of the given string.
     93  * @return The primary index if no error occurred, -1 or -2 otherwise.
     94  */
     95 DIVSUFSORT_API
     96 saidx_t
     97 divbwt(const sauchar_t *T, sauchar_t *U, saidx_t *A, saidx_t n);
     98 
     99 /**
    100  * Returns the version of the divsufsort library.
    101  * @return The version number string.
    102  */
    103 DIVSUFSORT_API
    104 const char *
    105 divsufsort_version(void);
    106 
    107 
    108 /**
    109  * Constructs the burrows-wheeler transformed string of a given string and suffix array.
    110  * @param T[0..n-1] The input string.
    111  * @param U[0..n-1] The output string. (can be T)
    112  * @param SA[0..n-1] The suffix array. (can be NULL)
    113  * @param n The length of the given string.
    114  * @param idx The output primary index.
    115  * @return 0 if no error occurred, -1 or -2 otherwise.
    116  */
    117 DIVSUFSORT_API
    118 saint_t
    119 bw_transform(const sauchar_t *T, sauchar_t *U,
    120              saidx_t *SA /* can NULL */,
    121              saidx_t n, saidx_t *idx);
    122 
    123 /**
    124  * Inverse BW-transforms a given BWTed string.
    125  * @param T[0..n-1] The input string.
    126  * @param U[0..n-1] The output string. (can be T)
    127  * @param A[0..n-1] The temporary array. (can be NULL)
    128  * @param n The length of the given string.
    129  * @param idx The primary index.
    130  * @return 0 if no error occurred, -1 or -2 otherwise.
    131  */
    132 DIVSUFSORT_API
    133 saint_t
    134 inverse_bw_transform(const sauchar_t *T, sauchar_t *U,
    135                      saidx_t *A /* can NULL */,
    136                      saidx_t n, saidx_t idx);
    137 
    138 /**
    139  * Checks the correctness of a given suffix array.
    140  * @param T[0..n-1] The input string.
    141  * @param SA[0..n-1] The input suffix array.
    142  * @param n The length of the given string.
    143  * @param verbose The verbose mode.
    144  * @return 0 if no error occurred.
    145  */
    146 DIVSUFSORT_API
    147 saint_t
    148 sufcheck(const sauchar_t *T, const saidx_t *SA, saidx_t n, saint_t verbose);
    149 
    150 /**
    151  * Search for the pattern P in the string T.
    152  * @param T[0..Tsize-1] The input string.
    153  * @param Tsize The length of the given string.
    154  * @param P[0..Psize-1] The input pattern string.
    155  * @param Psize The length of the given pattern string.
    156  * @param SA[0..SAsize-1] The input suffix array.
    157  * @param SAsize The length of the given suffix array.
    158  * @param idx The output index.
    159  * @return The count of matches if no error occurred, -1 otherwise.
    160  */
    161 DIVSUFSORT_API
    162 saidx_t
    163 sa_search(const sauchar_t *T, saidx_t Tsize,
    164           const sauchar_t *P, saidx_t Psize,
    165           const saidx_t *SA, saidx_t SAsize,
    166           saidx_t *left);
    167 
    168 /**
    169  * Search for the character c in the string T.
    170  * @param T[0..Tsize-1] The input string.
    171  * @param Tsize The length of the given string.
    172  * @param SA[0..SAsize-1] The input suffix array.
    173  * @param SAsize The length of the given suffix array.
    174  * @param c The input character.
    175  * @param idx The output index.
    176  * @return The count of matches if no error occurred, -1 otherwise.
    177  */
    178 DIVSUFSORT_API
    179 saidx_t
    180 sa_simplesearch(const sauchar_t *T, saidx_t Tsize,
    181                 const saidx_t *SA, saidx_t SAsize,
    182                 saint_t c, saidx_t *left);
    183 #endif
    184 
    185 #ifdef __cplusplus
    186 } /* extern "C" */
    187 #endif /* __cplusplus */
    188 
    189 #endif /* _DIVSUFSORT_H */

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.