hashtable.h

来自「一个学习SNMP项目:tmoerlan.」· C头文件 代码 · 共 37 行

H
37
字号
/* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks. * * hashtable.h : basic hash table library, used for managing the *   node-resident service namespace * * $Id: hashtable.h,v 1.2 2003/09/17 11:26:10 tmoerlan Exp $ */#include "list.h"typedef struct {  void *key;  void *value;} pair_t;typedef struct {  int (*cmp)(const void *,const void *);	/* for comparing the keys */  int (*hash)(void *);		/* for hashing the key */	  int max_len; 			/* max length of bucket list before resize */  list_t **tab;			/* the table: an array of lists of pairs */  int tab_sz;			/* size of the table */} hash_table_t;/* set to 1 when ht_lookup fails */int ht_errno;/* access functions */hash_table_t *ht_create(int sz,			int (*cmp)(const void *,const void *),			int (*hash)(void *));void ht_insert(hash_table_t *t, void *key, void *val);void *ht_lookup(hash_table_t *t, void *key);void ht_remove(hash_table_t * t, void *key);/* useful for tables indexed by strings */int hash_string(char *s);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?