libthai  0.1.14
Macros | Typedefs | Functions
tail.h File Reference

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

Tailtail_new ()
 Create a new tail object.
Tailtail_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 TrieChartail_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.

Detailed Description

trie tail for keeping suffixes


Macro Definition Documentation

#define tail_is_walkable_char (   t,
  s,
  suffix_idx,
 
)    (tail_get_suffix ((t), (s)) [suffix_idx] == (c))

Test walkability in tail with a character.

Parameters:
t: the tail data
s: the tail data index
suffix_idx: current character index in suffix
c: the character to test walkability
Returns:
boolean indicating 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.


Function Documentation

TrieIndex tail_add_suffix ( Tail t,
const TrieChar suffix 
)

Add a new suffix.

Parameters:
t: the tail data
suffix: the new suffix
Returns:
the index of the newly added suffix.

Add a new suffix entry to tail.

void tail_delete ( Tail t,
TrieIndex  index 
)

Delete suffix entry.

Parameters:
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.

Parameters:
t: the tail data
Returns:
0 on success, non-zero on failure

Free the given tail data.

TrieData tail_get_data ( const Tail t,
TrieIndex  index 
)

Get data associated to suffix entry.

Parameters:
t: the tail data
index: the index of the suffix
Returns:
the data associated to the suffix entry

Get data associated to suffix entry index in tail data.

const TrieChar* tail_get_suffix ( const Tail t,
TrieIndex  index 
)

Get suffix.

Parameters:
t: the tail data
index: the index of the suffix
Returns:
an allocated string of the indexed 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.

Parameters:
file: the file to read
Returns:
a pointer to the openned tail data, NULL on failure

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.

Bool tail_set_data ( Tail t,
TrieIndex  index,
TrieData  data 
)

Set data associated to suffix entry.

Parameters:
t: the tail data
index: the index of the suffix
data: the data to set
Returns:
boolean indicating success

Set data associated to suffix entry index in tail data.

Bool tail_set_suffix ( Tail t,
TrieIndex  index,
const TrieChar suffix 
)

Set suffix of existing entry.

Parameters:
t: the tail data
index: the index of the suffix
suffix: the new suffix

Set suffix of existing entry of given index in tail.

Bool tail_walk_char ( const Tail t,
TrieIndex  s,
short *  suffix_idx,
TrieChar  c 
)

Walk in tail with a character.

Parameters:
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
Returns:
boolean indicating success

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.

Parameters:
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
Returns:
total number of characters successfully walked

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.

Parameters:
t: the tail data
file: the file to write to
Returns:
0 on success, non-zero on failure

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.


Generated for libthai by doxygen 1.8.1.1