lst_stree

Name

lst_stree -- 

Synopsis



LST_STree*  lst_stree_new                   (LST_StringSet *strings);
void        lst_stree_free                  (LST_STree *tree);
int         lst_stree_init                  (LST_STree *tree);
void        lst_stree_clear                 (LST_STree *tree);
void        lst_stree_add_string            (LST_STree *tree,
                                             LST_String *string);
void        lst_stree_remove_string         (LST_STree *tree,
                                             LST_String *string);
int         lst_stree_get_string_index      (LST_STree *tree,
                                             LST_String *string);
void        lst_stree_allow_duplicates      (LST_STree *tree,
                                             int duplicates_flag);
LST_Node*   lst_node_get_parent             (LST_Node *node);
int         lst_node_is_leaf                (LST_Node *node);
int         lst_node_is_root                (LST_Node *node);
int         lst_node_get_string_length      (LST_Node *node);
LST_String* lst_node_get_string             (LST_Node *node,
                                             int max_depth);
int         lst_edge_get_length             (LST_Edge *edge);

Description

Details

lst_stree_new ()

LST_STree*  lst_stree_new                   (LST_StringSet *strings);

This is an implementation of Ukkonen's O(n) algorithm for creating a suffix tree. Upon return, the tree contains information on all the strings contained in the given string set. If you don't want to insert strings right away, just pass NULL.

strings :

set of strings to build tree with.

Returns :

new suffix tree.


lst_stree_free ()

void        lst_stree_free                  (LST_STree *tree);

The function releases all the memory claimed by the suffix tree. It does not touch any of the strings contained in the tree when called, it only cleans up the tree itself. Use when the tree was created with lst_stree_new().

tree :

tree to clean up.


lst_stree_init ()

int         lst_stree_init                  (LST_STree *tree);

This function initializes a tree structure that already exists. It is hence faster when you need a suffix tree in a tight loop as no data need be allocated and later on freed. It does not check if any data is existing in the structure when called; make sure you call lst_stree_clear() when you want to use the structure repeatedly.

tree :

tree structure to initialize.

Returns :

value > 0 when initialization was successful, 0 otherwise.


lst_stree_clear ()

void        lst_stree_clear                 (LST_STree *tree);

This is the counterpart to lst_stree_init(). It cleans up the tree but does not free the tree structure itself.

tree :

tree to clear.


lst_stree_add_string ()

void        lst_stree_add_string            (LST_STree *tree,
                                             LST_String *string);

The function adds string to the tree, unless he string is a duplicate of an existing string and duplicates are not allowed (see lst_stree_allow_duplicates()).

tree :

tree to add string to.

string :

string to add.


lst_stree_remove_string ()

void        lst_stree_remove_string         (LST_STree *tree,
                                             LST_String *string);

The function checks whether tree in fact contains string and if that's the case, removes it from the tree.

tree :

tree to remove string from.

string :

string to remove.


lst_stree_get_string_index ()

int         lst_stree_get_string_index      (LST_STree *tree,
                                             LST_String *string);

Within a suffix tree, every string contained in it is associated with an integer index value. This function returns that value.

tree :

tree to query.

string :

string to look up.

Returns :

index of string in tree.


lst_stree_allow_duplicates ()

void        lst_stree_allow_duplicates      (LST_STree *tree,
                                             int duplicates_flag);

Depending on the application of the suffix tree, it may be okay to have duplicates of strings in the tree or not. By default, duplicates are allowed. However, if you want to prevent insertion of a string that is already contained in the tree, pass 0.

tree :

tree to modify.

duplicates_flag :

whether to allow duplicates (> 0) or not (0).


lst_node_get_parent ()

LST_Node*   lst_node_get_parent             (LST_Node *node);

node :

node to find parent for.

Returns :

the parent node of a node, or NULL if no such node exists.


lst_node_is_leaf ()

int         lst_node_is_leaf                (LST_Node *node);

node :

node to check.

Returns :

value > 0 if node is a leaf, 0 otherwise.


lst_node_is_root ()

int         lst_node_is_root                (LST_Node *node);

node :

node to check.

Returns :

value > 0 if node is the root, 0 otherwise.


lst_node_get_string_length ()

int         lst_node_get_string_length      (LST_Node *node);

node :

node to query.

Returns :

the number of string items found on the edges iterated when going from the root down to node.


lst_node_get_string ()

LST_String* lst_node_get_string             (LST_Node *node,
                                             int max_depth);

node :

node whose string to return.

max_depth :

make string no longer than max_depth items.

Returns :

A newly allocated string consisting of all the string elements found when iterating from the root down to node.


lst_edge_get_length ()

int         lst_edge_get_length             (LST_Edge *edge);

edge :

edge to query.

Returns :

the length of the substring associated with that edge.