datrie/tail.h File Reference


Detailed Description

trie tail for keeping suffixes


Defines

#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 _Tail Tail
 Double-array structure type.

Functions

Tailtail_open (const char *path, const char *name, TrieIOMode mode)
 Open tail data from file.
int tail_close (Tail *t)
 Close tail data.
int tail_save (Tail *t)
 Save 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 (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 (Tail *t, TrieIndex s, short *suffix_idx, const TrieChar *str, int len)
 Walk in tail with a string.
Bool tail_walk_char (Tail *t, TrieIndex s, short *suffix_idx, TrieChar c)
 Walk in tail with a character.


Define 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.

int tail_close ( Tail t  ) 

Close tail data.

Parameters:
t : the tail data
Returns:
0 on success, non-zero on failure
Close the given tail data. If d was openned for writing, all pending changes will be saved to file.

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.

TrieData tail_get_data ( 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_open ( const char *  path,
const char *  name,
TrieIOMode  mode 
)

Open tail data from file.

Parameters:
path : the path that stores the tail files
name : the name of the tail data (not actual file name)
mode : openning mode, read or write
Returns:
a pointer to the openned tail data, NULL on failure
Open a tail data of given name. Note that name here does not mean the actual file name. Rather, the file name will be inferred by the name.

int tail_save ( Tail t  ) 

Save tail data.

Parameters:
t : the tail data
Returns:
0 on success, non-zero on failure
If t data was openned for writing, save all pending changes to file.

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 ( 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 ( 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.


Generated on Sat Oct 14 20:51:22 2006 for libdatrie by  doxygen 1.4.7