Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tst(3) [debian man page]

tst(3)							    InterNetNews Documentation							    tst(3)

NAME
tst - ternary search trie functions SYNOPSIS
#include <inn/tst.h> struct tst; struct tst *tst_init(int node_line_width); void tst_cleanup(struct tst *tst); int tst_insert(struct tst *tst, const unsigned char *key, void *data, int option, void **exist_ptr); void *tst_search(struct tst *tst, const unsigned char *key); void *tst_delete(struct tst *tst, const unsigned char *key); DESCRIPTION
tst_init allocates memory for members of struct tst, and allocates the first node_line_width nodes. A NULL pointer is returned by tst_init if any part of the memory allocation fails. On success, a pointer to a struct tst is returned. The value for node_line_width must be chosen very carefully. One node is required for every character in the tree. If you choose a value that is too small, your application will spend too much time calling malloc(3) and your node space will be too spread out. Too large a value is just a waste of space. tst_cleanup frees all memory allocated to nodes, internal structures, as well as tst itself. tst_insert inserts the string key into the tree. Behavior when a duplicate key is inserted is controlled by option. If key is already in the tree then TST_DUPLICATE_KEY is returned, and the data pointer for the existing key is placed in exist_ptr. If option is set to TST_REPLACE then the existing data pointer for the existing key is replaced by data. Note that the old data pointer will still be placed in exist_ptr. If a duplicate key is encountered and option is not set to TST_REPLACE then TST_DUPLICATE_KEY is returned. If key is zero length then TST_NULL_KEY is returned. A successful insert or replace returns TST_OK. A return value of TST_ERROR indicates that a memory allocation error occurred while trying to grow the node free. Note that the data argument must never be NULL. If it is, then calls to tst_search will fail for a key that exists because the data value was set to NULL, which is what tst_search returns. If you just want a simple existence tree, use the tst pointer as the data pointer. tst_search finds the string key in the tree if it exists and returns the data pointer associated with that key. If key is not found then NULL is returned, otherwise the data pointer associated with key is returned. tst_delete deletes the string key from the tree if it exists and returns the data pointer assocaited with that key. If key is not found then NULL is returned, otherwise the data pointer associated with key is returned. HISTORY
Converted to POD from Peter A. Friend's ternary search trie documentation by Alex Kiernan <alex.kiernan@thus.net> for InterNetNews 2.4.0. $Id: tst.pod 9074 2010-05-31 19:01:32Z iulius $ INN 2.5.3 2011-06-10 tst(3)

Check Out this Related Man Page

list(3) 						    InterNetNews Documentation							   list(3)

NAME
list - list routines SYNOPSIS
#include <inn/list.h> struct node { struct node *succ; struct node *pred; }; struct list { struct node *head; struct node *tail; struct node *tailpred; }; void list_new(struct list *list); struct node *list_addhead(struct list *list, struct node *node); struct node *list_addtail(struct list *list, struct node *node); struct node *list_head(struct list *list); struct node *list_tail(struct list *list); struct node *list_succ(struct node *node); struct node *list_pred(struct node *node); struct node *list_remhead(struct list *list); struct node *list_remtail(struct list *list); struct node *list_remove(struct node *node); struct node *list_insert(struct list *list, struct node *node, struct node *pred); bool list_isempty(struct list *list); DESCRIPTION
list_new initialises the list header list so as to create an empty list. list_addhead adds node to the head of list, returning the node just added. list_addtail adds node to the tail of list, returning the node just added. list_head returns a pointer to the the node at the head of list or NULL if the list is empty. list_tail returns a pointer to the the node at the tail of list or NULL if the list is empty. list_succ returns the next (successor) node on the list after node or NULL if node was the final node. list_pred returns the previous (predecessor) node on the list before node or NULL if node was the first node. list_remhead removes the first node from list and returns it to the caller. If the list is empty NULL is returned. list_remtail removes the last node from list and returns it to the caller. If the list is empty NULL is returned. list_remove removes node from the list it is on and returns it to the caller. list_insert inserts node onto list after the node pred. If pred is NULL then node is added to the head of list. HISTORY
Written by Alex Kiernan <alex.kiernan@thus.net> for InterNetNews 2.4.0. $Id: list.pod 9074 2010-05-31 19:01:32Z iulius $ INN 2.5.3 2011-06-10 list(3)
Man Page