mtab.h

00001 #ifndef _CP_MTAB_H
00002 #define _CP_MTAB_H
00003 
00004 #include "common.h"
00005 #include "collection.h"
00006 
00007 __BEGIN_DECLS
00008 
00009 #include "config.h"
00010 
00011 /*
00012  * table entry descriptor. mtab entries map a character to a value, and in 
00013  * addition allow specifying an attribute for the mapping. this is used by 
00014  * cp_trie to collapse multiple single child trie edges into a single node.
00015  */
00016 typedef struct _mtab_node
00017 {
00018     unsigned char key;
00019     void *value;
00020     void *attr;
00021     struct _mtab_node *next;
00022 } mtab_node;
00023 
00024 mtab_node *mtab_node_new(unsigned char key, void *value, void *attr);
00025 
00026 /* 
00027  * the 'owner' parameter is for use by the enclosing data structure. cp_trie
00028  * uses this to recursively delete a sub-tree.
00029  */
00030 typedef void *(*mtab_dtr)(void *owner, mtab_node *node);
00031 
00032 /*
00033  * mtab is a hash table implementation specialized for use as a holder for 
00034  * cp_trie edges. 
00035  */
00036 typedef struct _mtab
00037 {
00038     int size;
00039     int items;
00040     mtab_node **table;
00041 } mtab;
00042 
00043 mtab *mtab_new(int size);
00044 
00045 void mtab_delete(mtab *t);
00046 void mtab_delete_custom(mtab *t, 
00047                         void *owner, 
00048                         mtab_dtr dtr);
00049 mtab_node *mtab_put(mtab *t, unsigned char key, void *value, void *attr);
00050 mtab_node *mtab_get(mtab *t, unsigned char key);
00051 void *mtab_remove(mtab *t, unsigned char key);
00052 
00053 int mtab_count(mtab *t);
00054 
00055 int mtab_callback(mtab *t, cp_callback_fn fn, void *prm);
00056 
00057 __END_DECLS
00058 
00059 #endif

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