cp_splaytree

Section: libcprops - cp_splaytree (3)
Updated: MAY 2006
Index Return to Main Contents [view source]
 

NAME

cp_splaytree - an splay tree implementation

 

DESCRIPTION

cp_splaytree is a general purpose splay tree implementation. In splay trees, every tree operation (insert, delete, lookup) brings the affected node to the root of the tree. This makes splay trees useful for applications where the search space is much larger than the group of mappings most frequently accessed. A drawback in applications where the tree can be accessed from multiple threads is that since the lookup operation changes the tree structure, the tree must be write- locked during lookup. In other collection implementations lookup requires a read-lock only, allowing simultaneous access from multiple readers.

A tree is created with cp_splaytree_create(3) or cp_splaytree_destroy(3). After creation behavior may be changed by calling cp_splaytree_set_mode(3) and cp_splaytree_unset_mode(3) to set and unset mode bits. Mappings may be added with cp_splaytree_get(3) and removed with cp_splaytree_delete(3). For more details see the documentation for specific functions.

 

INTERFACE

the following is a summary of functions provided by <cprops/splay.h>.

cp_splaytree *cp_splaytree_create(cp_compare_fn cmp);
cp_splaytree *
      cp_splaytree_create_by_option(int mode,
                                    cp_compare_fn compare_fn,
                                    cp_copy_fn copy_key,
                                    cp_destructor_fn free_key);
                                    cp_copy_fn copy_value
                                    cp_destructor_fn free_value);

void cp_splaytree_destroy(cp_splaytree *tree);
void cp_splaytree_destroy_custom(cp_splaytree *tree,
                                  cp_destructor_fn dk,
                                  cp_destructor_fn dv);

void *cp_splaytree_insert(cp_splaytree *tree, void *key, void *value);
void *cp_splaytree_get(cp_splaytree *tree, void *key);
void *cp_splaytree_delete(cp_splaytree *tree, void *key);
int cp_splaytree_contains(cp_splaytree *tree, void *key);
long cp_splaytree_count(cp_splaytree *tree);

int cp_splaytree_get_mode(cp_splaytree *tree);
void cp_splaytree_set_mode(cp_splaytree *tree, int mode);
void cp_splaytree_unset_mode(cp_splaytree *tree, int mode);

int cp_splaytree_lock(cp_splaytree *tree, int type);
int cp_splaytree_unlock(cp_splaytree *tree);
int cp_splaytree_rdlock(cp_splaytree *tree);
int cp_splaytree_wrlock(cp_splaytree *tree);

 

SEE ALSO

cp_splaytree_create(3), cp_splaytree_insert(3), cp_splaytree_lock(3), cp_splaytree_set_mode(3), cprops(3)


 

Index

NAME
DESCRIPTION
INTERFACE
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 10:00:49 GMT, May 30, 2006
SourceForge.net Logo