Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
extractor
gesa
Commits
00e56266
Commit
00e56266
authored
Jan 11, 2018
by
jkvis
Browse files
Added utility functions
parent
b832e295
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/utils.c
0 → 100644
View file @
00e56266
#include <stdlib.h>
#include "../include/gesa.h"
int
GESA_calculate_lcp
(
GESA_char_t
const
*
const
string
,
size_t
const
length
,
GESA_index_t
const
*
const
sa
,
GESA_index_t
*
const
lcp
)
{
GESA_index_t
*
const
rank
=
malloc
(
length
*
sizeof
(
*
rank
));
if
(
rank
==
NULL
)
{
return
1
;
// memory allocation failed
}
// if
for
(
size_t
i
=
0
;
i
<
length
;
++
i
)
{
rank
[
sa
[
i
]]
=
i
;
}
// for
GESA_index_t
h
=
0
;
for
(
size_t
i
=
0
;
i
<
length
;
++
i
)
{
if
(
rank
[
i
]
>
0
)
{
GESA_index_t
const
j
=
sa
[
rank
[
i
]
-
1
];
while
((
size_t
)
i
+
h
<
length
&&
(
size_t
)
j
+
h
<
length
&&
string
[
i
+
h
]
==
string
[
j
+
h
])
{
h
+=
1
;
}
// while
lcp
[
rank
[
i
]]
=
h
;
if
(
h
>
0
)
{
h
-=
1
;
}
// if
}
// if
}
// for
free
(
rank
);
return
0
;
}
// GESA_calculate_lcp
int
GESA_calculate_childtab
(
GESA
const
*
const
gesa
,
GESA_index_t
*
const
childtab
)
{
static
size_t
const
STACK_SIZE
=
2048
;
GESA_index_t
stack
[
STACK_SIZE
];
}
// GESA_calculate_childtab
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment