chtbl.h
来自「掌握如何用C来实现各种算法」· C头文件 代码 · 共 53 行
H
53 行
/*****************************************************************************
* *
* ------------------------------- chtbl.h -------------------------------- *
* *
*****************************************************************************/
#ifndef CHTBL_H
#define CHTBL_H
#include <stdlib.h>
#include "list.h"
/*****************************************************************************
* *
* Define a structure for chained hash tables. *
* *
*****************************************************************************/
typedef struct CHTbl_ {
int buckets;
int (*h)(const void *key);
int (*match)(const void *key1, const void *key2);
void (*destroy)(void *data);
int size;
List *table;
} CHTbl;
/*****************************************************************************
* *
* --------------------------- Public Interface --------------------------- *
* *
*****************************************************************************/
int chtbl_init(CHTbl *htbl, int buckets, int (*h)(const void *key), int
(*match)(const void *key1, const void *key2), void (*destroy)(void *data));
void chtbl_destroy(CHTbl *htbl);
int chtbl_insert(CHTbl *htbl, const void *data);
int chtbl_remove(CHTbl *htbl, void **data);
int chtbl_lookup(const CHTbl *htbl, void **data);
#define chtbl_size(htbl) ((htbl)->size)
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?