*
*/
-#define OFFSET(item,link) ((char *)link - (char *)item)
+/*
+ * Loop var through each member of table
+ */
+#define foreach_htable(var, tbl) \
+ for(((void *)(var))=(tbl)->first(); \
+ (var); \
+ ((void *)(var))=(tbl)->next())
struct hlink {
void *next; /* next hash item */
void hash_index(char *key); /* produce hash key,index */
void grow_table(); /* grow the table */
public:
- htable(void *item, void *link);
- void init(void *item, void *link);
+ htable(void *item, void *link, int tsize = 31);
+ void init(void *item, void *link, int tsize = 31);
bool insert(char *key, void *item);
void *lookup(char *key);
void *first(); /* get first item in table */
void *next(); /* get next item in table */
void destroy();
+ void stats(); /* print stats about the table */
+ uint32_t size(); /* return size of table */
void * operator new(size_t);
void operator delete(void *);
};