-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsacak-lcp.h
82 lines (70 loc) · 2.16 KB
/
sacak-lcp.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Authors: Felipe A. Louza, Simon Gog, Guilherme P. Telles
* contact: [email protected]
* 22/03/2017
*/
/*
* This code is a modification of SACA-K algorithm by G. Nong, which can be
* retrieved at: http://code.google.com/p/ge-nong/
*
* Our algorithm, SACA-K+LCP, constructs the suffix array and the LCP array
* for a string s[0,n-1] in {0..\sigma-1}^n in O(n)-time using O(\sigma \log n)
* bits of additional space (workspace)
*
*/
#ifndef SACA_K_H
#define SACA_K_H
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <inttypes.h>
#include <string.h>
#include <time.h>
#define max(a,b) ((a) > (b) ? (a) : (b))
#ifndef DEBUG
#define DEBUG 0
#endif
#ifndef M64
#define M64 0
#endif
#if M64
typedef int64_t int_t;
typedef uint64_t uint_t;
#define PRIdN PRId64
#define U_MAX UINT64_MAX
#define I_MAX INT64_MAX
#define I_MIN INT64_MIN
#else
typedef int32_t int_t;
typedef uint32_t uint_t;
#define PRIdN PRId32
#define U_MAX UINT32_MAX
#define I_MAX INT32_MAX
#define I_MIN INT32_MIN
#endif
/** @brief computes the suffix array of string s[0..n-1]
*
* @param s input string with s[n-1]=0
* @param SA suffix array
* @param n string length
* @return -1 if an error occured, otherwise the depth of the recursive calls.
*/
int sacak(unsigned char *s, uint_t *SA, uint_t n);
/** @brief computes the suffix array of string s[0..n-1]
* @param k alphabet size
*/
int sacak_int(int_t *s, uint_t *SA, uint_t n, uint_t k);
/** @brief computes the suffix and LCP arrays of string s[0..n-1]
*
* @param s input string with s[n-1]=0
* @param SA suffix array
* @param LCP LCP array
* @param n string length
* @return -1 if an error occured, otherwise the depth of the recursive calls.
*/
int sacak_lcp(unsigned char *s, uint_t *SA, int_t* LCP, uint_t n);
/** @brief computes the suffix and LCP arrays of string s[0..n-1]
* @param k alphabet size
*/
int sacak_lcp_int(int_t *s, uint_t *SA, int_t* LCP, uint_t n, uint_t k);
#endif