libthai
0.1.14
|
trie tail for keeping suffixes More...
Macros | |
#define | tail_is_walkable_char(t, s, suffix_idx, c) (tail_get_suffix ((t), (s)) [suffix_idx] == (c)) |
Test walkability in tail with a character. |
Typedefs | |
typedef struct _Tail | Tail |
Double-array structure type. |
Functions | |
Tail * | tail_new () |
Create a new tail object. | |
Tail * | tail_read (FILE *file) |
Read tail data from file. | |
void | tail_free (Tail *t) |
Free tail data. | |
int | tail_write (const Tail *t, FILE *file) |
Write tail data. | |
const TrieChar * | tail_get_suffix (const Tail *t, TrieIndex index) |
Get suffix. | |
Bool | tail_set_suffix (Tail *t, TrieIndex index, const TrieChar *suffix) |
Set suffix of existing entry. | |
TrieIndex | tail_add_suffix (Tail *t, const TrieChar *suffix) |
Add a new suffix. | |
TrieData | tail_get_data (const Tail *t, TrieIndex index) |
Get data associated to suffix entry. | |
Bool | tail_set_data (Tail *t, TrieIndex index, TrieData data) |
Set data associated to suffix entry. | |
void | tail_delete (Tail *t, TrieIndex index) |
Delete suffix entry. | |
int | tail_walk_str (const Tail *t, TrieIndex s, short *suffix_idx, const TrieChar *str, int len) |
Walk in tail with a string. | |
Bool | tail_walk_char (const Tail *t, TrieIndex s, short *suffix_idx, TrieChar c) |
Walk in tail with a character. |
trie tail for keeping suffixes
#define tail_is_walkable_char | ( | t, | |
s, | |||
suffix_idx, | |||
c | |||
) | (tail_get_suffix ((t), (s)) [suffix_idx] == (c)) |
Test walkability in tail with a character.
t | : the tail data |
s | : the tail data index |
suffix_idx | : current character index in suffix |
c | : the character to test walkability |
Test if the character c can be used to walk from given character position suffix_idx of entry s of the tail data t.
Add a new suffix.
t | : the tail data |
suffix | : the new suffix |
Add a new suffix entry to tail.
Delete suffix entry.
t | : the tail data |
index | : the index of the suffix to delete |
Delete suffix entry from the tail data.
void tail_free | ( | Tail * | t | ) |
Free tail data.
t | : the tail data |
Free the given tail data.
Get data associated to suffix entry.
t | : the tail data |
index | : the index of the suffix |
Get data associated to suffix entry index in tail data.
Get suffix.
t | : the tail data |
index | : the index of the suffix |
Get suffix from tail with given index. The returned string is allocated. The caller should free it with free().
Tail* tail_new | ( | ) |
Create a new tail object.
Create a new empty tail object.
Tail* tail_read | ( | FILE * | file | ) |
Read tail data from file.
file | : the file to read |
Read tail data from the opened file, starting from the current file pointer until the end of tail data block. On return, the file pointer is left at the position after the read block.
Set data associated to suffix entry.
t | : the tail data |
index | : the index of the suffix |
data | : the data to set |
Set data associated to suffix entry index in tail data.
Set suffix of existing entry.
t | : the tail data |
index | : the index of the suffix |
suffix | : the new suffix |
Set suffix of existing entry of given index in tail.
Walk in tail with a character.
t | : the tail data |
s | : the tail data index |
suffix_idx | : pointer to current character index in suffix |
c | : the character to use in walking |
Walk in the tail data t at entry s, from given character position *suffix_idx, using given character c. If the walk is successful, it returns TRUE, and *suffix_idx is updated to the next character. Otherwise, it returns FALSE, and *suffix_idx is left unchanged.
int tail_walk_str | ( | const Tail * | t, |
TrieIndex | s, | ||
short * | suffix_idx, | ||
const TrieChar * | str, | ||
int | len | ||
) |
Walk in tail with a string.
t | : the tail data |
s | : the tail data index |
suffix_idx | : pointer to current character index in suffix |
str | : the string to use in walking |
len | : total characters in str to walk |
Walk in the tail data t at entry s, from given character position *suffix_idx, using len characters of given string str. On return, *suffix_idx is updated to the position after the last successful walk, and the function returns the total number of character succesfully walked.
int tail_write | ( | const Tail * | t, |
FILE * | file | ||
) |
Write tail data.
t | : the tail data |
file | : the file to write to |
Write tail data to the given file, starting from the current file pointer. On return, the file pointer is left after the tail data block.