2 * divsufsort64.h for libdivsufsort64
3 * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
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
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
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.
27 #ifndef _DIVSUFSORT64_H
28 #define _DIVSUFSORT64_H 1
32 #endif /* __cplusplus */
36 #ifndef DIVSUFSORT_API
37 # ifdef DIVSUFSORT_BUILD_DLL
38 # define DIVSUFSORT_API
40 # define DIVSUFSORT_API
47 typedef uint8_t sauchar_t;
48 #endif /* SAUCHAR_T */
51 typedef int32_t saint_t;
55 typedef int64_t saidx64_t;
56 #endif /* SAIDX64_T */
58 #define PRIdSAINT_T PRId32
59 #endif /* PRIdSAINT_T */
61 #define PRIdSAIDX64_T PRId64
62 #endif /* PRIdSAIDX64_T */
68 * Constructs the suffix array of a given string.
69 * @param T[0..n-1] The input string.
70 * @param SA[0..n-1] The output array of suffixes.
71 * @param n The length of the given string.
72 * @return 0 if no error occurred, -1 or -2 otherwise.
76 divsufsort64(const sauchar_t *T, saidx64_t *SA, saidx64_t n);
79 * Constructs the burrows-wheeler transformed string of a given string.
80 * @param T[0..n-1] The input string.
81 * @param U[0..n-1] The output string. (can be T)
82 * @param A[0..n-1] The temporary array. (can be NULL)
83 * @param n The length of the given string.
84 * @return The primary index if no error occurred, -1 or -2 otherwise.
88 divbwt64(const sauchar_t *T, sauchar_t *U, saidx64_t *A, saidx64_t n);
91 * Returns the version of the divsufsort library.
92 * @return The version number string.
96 divsufsort64_version(void);
100 * Constructs the burrows-wheeler transformed string of a given string and suffix array.
101 * @param T[0..n-1] The input string.
102 * @param U[0..n-1] The output string. (can be T)
103 * @param SA[0..n-1] The suffix array. (can be NULL)
104 * @param n The length of the given string.
105 * @param idx The output primary index.
106 * @return 0 if no error occurred, -1 or -2 otherwise.
110 bw_transform64(const sauchar_t *T, sauchar_t *U,
111 saidx64_t *SA /* can NULL */,
112 saidx64_t n, saidx64_t *idx);
115 * Inverse BW-transforms a given BWTed string.
116 * @param T[0..n-1] The input string.
117 * @param U[0..n-1] The output string. (can be T)
118 * @param A[0..n-1] The temporary array. (can be NULL)
119 * @param n The length of the given string.
120 * @param idx The primary index.
121 * @return 0 if no error occurred, -1 or -2 otherwise.
125 inverse_bw_transform64(const sauchar_t *T, sauchar_t *U,
126 saidx64_t *A /* can NULL */,
127 saidx64_t n, saidx64_t idx);
130 * Checks the correctness of a given suffix array.
131 * @param T[0..n-1] The input string.
132 * @param SA[0..n-1] The input suffix array.
133 * @param n The length of the given string.
134 * @param verbose The verbose mode.
135 * @return 0 if no error occurred.
139 sufcheck64(const sauchar_t *T, const saidx64_t *SA, saidx64_t n, saint_t verbose);
142 * Search for the pattern P in the string T.
143 * @param T[0..Tsize-1] The input string.
144 * @param Tsize The length of the given string.
145 * @param P[0..Psize-1] The input pattern string.
146 * @param Psize The length of the given pattern string.
147 * @param SA[0..SAsize-1] The input suffix array.
148 * @param SAsize The length of the given suffix array.
149 * @param idx The output index.
150 * @return The count of matches if no error occurred, -1 otherwise.
154 sa_search64(const sauchar_t *T, saidx64_t Tsize,
155 const sauchar_t *P, saidx64_t Psize,
156 const saidx64_t *SA, saidx64_t SAsize,
160 * Search for the character c in the string T.
161 * @param T[0..Tsize-1] The input string.
162 * @param Tsize The length of the given string.
163 * @param SA[0..SAsize-1] The input suffix array.
164 * @param SAsize The length of the given suffix array.
165 * @param c The input character.
166 * @param idx The output index.
167 * @return The count of matches if no error occurred, -1 otherwise.
171 sa_simplesearch64(const sauchar_t *T, saidx64_t Tsize,
172 const saidx64_t *SA, saidx64_t SAsize,
173 saint_t c, saidx64_t *left);
178 #endif /* __cplusplus */
180 #endif /* _DIVSUFSORT64_H */