wtrie.h

Go to the documentation of this file.
00001 #ifndef _CP_WRTREE_H
00002 #define _CP_WRTREE_H
00003 
00009 #include "common.h"
00010 
00011 __BEGIN_DECLS
00012 
00013 #include "config.h"
00014 
00015 #include <string.h>
00016 #include <errno.h>
00017 #include "hashtable.h"
00018 #include "vector.h"
00019 #include "wtab.h"
00020 #include "mempool.h"
00021 
00022 #define WNODE_MATCH(n, i) ((n)->others ? wtab_get((n)->others, *i) : NULL)
00023 #define BRANCH_COUNT(node) wtab_count((node)->others)
00024 
00025 typedef int (*cp_wtrie_match_fn)(void *leaf); 
00026 
00027 CPROPS_DLL struct _cp_wtrie;
00028 
00029 /* 
00030  * cp_wtrie nodes can have any number of subnodes mapped by an wtab - a hash
00031  * table designed for wide character keys
00032  */
00033 typedef CPROPS_DLL struct _cp_wtrie_node 
00034 { 
00035     wtab *others; 
00036     void *leaf; 
00037 } cp_wtrie_node; 
00038 
00039 CPROPS_DLL
00040 cp_wtrie_node *cp_wtrie_node_new(void *leaf, cp_mempool *pool); 
00041 CPROPS_DLL
00042 void *cp_wtrie_node_delete(struct _cp_wtrie *grp, cp_wtrie_node *node);
00043 CPROPS_DLL
00044 void cp_wtrie_delete_mapping(struct _cp_wtrie *grp, wtab_node *map_node);
00045 
00046 CPROPS_DLL
00047 void cp_wtrie_node_unmap(struct _cp_wtrie *grp, cp_wtrie_node **node); 
00048 
00057 typedef CPROPS_DLL struct _cp_wtrie
00058 { 
00059     cp_wtrie_node *root;                
00060     int path_count;                    
00062     int mode;                          
00064     cp_copy_fn copy_leaf;              
00065     cp_destructor_fn delete_leaf;      
00067     cp_lock *lock;                     
00068     cp_thread txowner;                 
00069     int txtype;                        
00071     cp_mempool *mempool;               
00072 } cp_wtrie; 
00073 
00078 CPROPS_DLL
00079 cp_wtrie *cp_wtrie_create_wtrie(int mode, 
00080                              cp_copy_fn copy_leaf, 
00081                              cp_destructor_fn delete_leaf);
00082 
00084 CPROPS_DLL
00085 cp_wtrie *cp_wtrie_create(int mode);
00087 CPROPS_DLL
00088 int cp_wtrie_destroy(cp_wtrie *grp); 
00090 CPROPS_DLL
00091 int cp_wtrie_add(cp_wtrie *grp, wchar_t *key, void *leaf); 
00093 CPROPS_DLL
00094 int cp_wtrie_remove(cp_wtrie *grp, wchar_t *key, void **leaf); 
00096 CPROPS_DLL
00097 int cp_wtrie_prefix_match(cp_wtrie *grp, wchar_t *key, void **leaf);
00099 CPROPS_DLL
00100 void *cp_wtrie_exact_match(cp_wtrie *grp, wchar_t *key);
00102 CPROPS_DLL
00103 cp_vector *cp_wtrie_fetch_matches(cp_wtrie *grp, wchar_t *key);
00105 CPROPS_DLL
00106 cp_vector *cp_wtrie_submatch(cp_wtrie *grp, wchar_t *key);
00107 
00109 CPROPS_DLL
00110 int cp_wtrie_count(cp_wtrie *grp);
00111 
00112 CPROPS_DLL
00113 void cp_wtrie_set_root(cp_wtrie *grp, void *leaf); 
00114 
00115 CPROPS_DLL
00116 int cp_wtrie_lock(cp_wtrie *grp, int type);
00117 #define cp_wtrie_rdlock(grp) (cp_wtrie_lock(grp, COLLECTION_LOCK_READ))
00118 #define cp_wtrie_wrlock(grp) (cp_wtrie_lock(grp, COLLECTION_LOCK_WRITE))
00119 CPROPS_DLL
00120 int cp_wtrie_unlock(cp_wtrie *grp);
00121 
00122 /* get the current collection mode */
00123 CPROPS_DLL
00124 int cp_wtrie_get_mode(cp_wtrie *grp);
00125 /* sets the bits defined by mode on the wtrie mode */
00126 CPROPS_DLL
00127 int cp_wtrie_set_mode(cp_wtrie *grp, int mode);
00128 /* clears the bits defined by mode on the wtrie mode */
00129 CPROPS_DLL
00130 int cp_wtrie_unset_mode(cp_wtrie *grp, int mode);
00131 
00132 CPROPS_DLL
00133 void cp_wtrie_dump(cp_wtrie *grp);
00134 
00135 /* set wtrie to use given mempool or allocate a new one if pool is NULL */
00136 CPROPS_DLL
00137 int cp_wtrie_use_mempool(cp_wtrie *tree, cp_mempool *pool);
00138 
00139 /* set wtrie to use a shared memory pool */
00140 CPROPS_DLL
00141 int cp_wtrie_share_mempool(cp_wtrie *tree, cp_shared_mempool *pool);
00142 
00143 __END_DECLS
00144 
00147 #endif
00148 

Generated on Mon Dec 5 23:00:22 2011 for cprops by  doxygen 1.4.7