xref: /freebsd/sys/contrib/zstd/lib/dictBuilder/divsufsort.h (revision 55b1c6e7e4a6909004e13c6d2f328f911a8e7b83)
1*0c16b537SWarner Losh /*
2*0c16b537SWarner Losh  * divsufsort.h for libdivsufsort-lite
3*0c16b537SWarner Losh  * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
4*0c16b537SWarner Losh  *
5*0c16b537SWarner Losh  * Permission is hereby granted, free of charge, to any person
6*0c16b537SWarner Losh  * obtaining a copy of this software and associated documentation
7*0c16b537SWarner Losh  * files (the "Software"), to deal in the Software without
8*0c16b537SWarner Losh  * restriction, including without limitation the rights to use,
9*0c16b537SWarner Losh  * copy, modify, merge, publish, distribute, sublicense, and/or sell
10*0c16b537SWarner Losh  * copies of the Software, and to permit persons to whom the
11*0c16b537SWarner Losh  * Software is furnished to do so, subject to the following
12*0c16b537SWarner Losh  * conditions:
13*0c16b537SWarner Losh  *
14*0c16b537SWarner Losh  * The above copyright notice and this permission notice shall be
15*0c16b537SWarner Losh  * included in all copies or substantial portions of the Software.
16*0c16b537SWarner Losh  *
17*0c16b537SWarner Losh  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18*0c16b537SWarner Losh  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19*0c16b537SWarner Losh  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20*0c16b537SWarner Losh  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21*0c16b537SWarner Losh  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22*0c16b537SWarner Losh  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23*0c16b537SWarner Losh  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24*0c16b537SWarner Losh  * OTHER DEALINGS IN THE SOFTWARE.
25*0c16b537SWarner Losh  */
26*0c16b537SWarner Losh 
27*0c16b537SWarner Losh #ifndef _DIVSUFSORT_H
28*0c16b537SWarner Losh #define _DIVSUFSORT_H 1
29*0c16b537SWarner Losh 
30*0c16b537SWarner Losh #ifdef __cplusplus
31*0c16b537SWarner Losh extern "C" {
32*0c16b537SWarner Losh #endif /* __cplusplus */
33*0c16b537SWarner Losh 
34*0c16b537SWarner Losh 
35*0c16b537SWarner Losh /*- Prototypes -*/
36*0c16b537SWarner Losh 
37*0c16b537SWarner Losh /**
38*0c16b537SWarner Losh  * Constructs the suffix array of a given string.
39*0c16b537SWarner Losh  * @param T [0..n-1] The input string.
40*0c16b537SWarner Losh  * @param SA [0..n-1] The output array of suffixes.
41*0c16b537SWarner Losh  * @param n The length of the given string.
42*0c16b537SWarner Losh  * @param openMP enables OpenMP optimization.
43*0c16b537SWarner Losh  * @return 0 if no error occurred, -1 or -2 otherwise.
44*0c16b537SWarner Losh  */
45*0c16b537SWarner Losh int
46*0c16b537SWarner Losh divsufsort(const unsigned char *T, int *SA, int n, int openMP);
47*0c16b537SWarner Losh 
48*0c16b537SWarner Losh /**
49*0c16b537SWarner Losh  * Constructs the burrows-wheeler transformed string of a given string.
50*0c16b537SWarner Losh  * @param T [0..n-1] The input string.
51*0c16b537SWarner Losh  * @param U [0..n-1] The output string. (can be T)
52*0c16b537SWarner Losh  * @param A [0..n-1] The temporary array. (can be NULL)
53*0c16b537SWarner Losh  * @param n The length of the given string.
54*0c16b537SWarner Losh  * @param num_indexes The length of secondary indexes array. (can be NULL)
55*0c16b537SWarner Losh  * @param indexes The secondary indexes array. (can be NULL)
56*0c16b537SWarner Losh  * @param openMP enables OpenMP optimization.
57*0c16b537SWarner Losh  * @return The primary index if no error occurred, -1 or -2 otherwise.
58*0c16b537SWarner Losh  */
59*0c16b537SWarner Losh int
60*0c16b537SWarner Losh divbwt(const unsigned char *T, unsigned char *U, int *A, int n, unsigned char * num_indexes, int * indexes, int openMP);
61*0c16b537SWarner Losh 
62*0c16b537SWarner Losh 
63*0c16b537SWarner Losh #ifdef __cplusplus
64*0c16b537SWarner Losh } /* extern "C" */
65*0c16b537SWarner Losh #endif /* __cplusplus */
66*0c16b537SWarner Losh 
67*0c16b537SWarner Losh #endif /* _DIVSUFSORT_H */
68