wtab.h

00001 #ifndef _CP_WTAB_H
00002 #define _CP_WTAB_H
00003 
00004 #include "common.h"
00005 #include "collection.h"
00006 
00007 __BEGIN_DECLS
00008 
00009 #include "config.h"
00010 
00011 #include <wchar.h>
00012 
00013 /*
00014  * table entry descriptor. wtab entries map a character to a value, and in 
00015  * addition allow specifying an attribute for the mapping. this is used by 
00016  * cp_trie to collapse multiple single child trie edges into a single node.
00017  */
00018 typedef struct _wtab_node
00019 {
00020     wchar_t key;
00021     void *value;
00022     void *attr;
00023     struct _wtab_node *next;
00024 } wtab_node;
00025 
00026 wtab_node *wtab_node_new(wchar_t key, void *value, void *attr);
00027 
00028 /* 
00029  * the 'owner' parameter is for use by the enclosing data structure. cp_trie
00030  * uses this to recursively delete a sub-tree.
00031  */
00032 typedef void *(*wtab_dtr)(void *owner, wtab_node *node);
00033 
00034 /*
00035  * wtab is a hash table implementation specialized for use as a holder for 
00036  * cp_trie edges. 
00037  */
00038 typedef struct _wtab
00039 {
00040     int size;
00041     int items;
00042     wtab_node **table;
00043 } wtab;
00044 
00045 wtab *wtab_new(int size);
00046 
00047 void wtab_delete(wtab *t);
00048 void wtab_delete_custom(wtab *t, 
00049                         void *owner, 
00050                         wtab_dtr dtr);
00051 wtab_node *wtab_put(wtab *t, wchar_t key, void *value, void *attr);
00052 wtab_node *wtab_get(wtab *t, wchar_t key);
00053 void *wtab_remove(wtab *t, wchar_t key);
00054 
00055 int wtab_count(wtab *t);
00056 
00057 int wtab_callback(wtab *t, cp_callback_fn fn, void *prm);
00058 
00059 __END_DECLS
00060 
00061 #endif

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