⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hash.h

📁 常用数据结构算法代码库
💻 H
字号:
/****************************************************************************
*
*					Copyright (C) 1991 Kendall Bennett.
*							All rights reserved.
*
* Filename:		$RCSfile: hash.h $
* Version:		$Revision: 1.5 $
*
* Language:		ANSI C
* Environment:	any
*
* Description:	Header file for hash table module.
*
* $Id: hash.h 1.5 91/12/31 19:41:11 kjb Exp $
*
* Revision History:
* -----------------
*
* $Log:	hash.h $
* Revision 1.5  91/12/31  19:41:11  kjb
* 
* Modified include files directories.
* 
* Revision 1.4  91/09/27  03:11:00  kjb
* Added compatibility with C++.
* 
* Revision 1.3  91/09/26  10:07:36  kjb
* Took out extern references
* 
* Revision 1.2  91/09/02  11:11:53  ROOT_DOS
* Minor revision. Added function hsh_kill() to remove the hash table and all
* symbols in the hash table.
* 
* Revision 1.1  91/08/16  13:19:37  ROOT_DOS
* Initial revision
*
****************************************************************************/

#ifndef	__HASH_H
#define	__HASH_H

#ifndef	__DEBUG_H
#include "debug.h"
#endif

/*---------------------- Macros and type definitions ----------------------*/

typedef struct HSH_BUCKET {
	struct HSH_BUCKET	*next;
	struct HSH_BUCKET	**prev;
	} HSH_BUCKET;

typedef struct {
	int			size;		/* Max number of elements in table			*/
	int			numsyms;	/* Number of elements currently in table	*/
	unsigned	(*hash)(void *);		/* The hash function			*/
	int			(*cmp)(void *,void *);	/* Comparison function			*/
	HSH_BUCKET	*table[1];	/* First element of actual hash table		*/
	} HASH_TAB;

/* Return a pointer to the user space given the address of the header of
 * a symbol.
 */

#define	HSH_USERSPACE(h)	((void*)((HSH_BUCKET*)(h) + 1))

/* Return a pointer to the header of a symbol, given the address of the
 * user space.
 */

#define	HSH_HEADER(n)		((HSH_BUCKET*)(n) - 1)

/*-------------------------- Function Prototypes --------------------------*/

#ifdef __cplusplus
extern "C" {
#endif

void *hsh_newsym(int size);
void hsh_freesym(void *sym);
HASH_TAB *hsh_init(unsigned maxsym, unsigned (*hash_function)(void *),
				   int (*cmp_function)(void *, void *) );
void hsh_kill(HASH_TAB *tabp, void (*freeSym)(void *));
void *hsh_addsym(HASH_TAB *tabp, void *isym);
void hsh_delsym(HASH_TAB *tabp, void *isym);
void *hsh_findsym(HASH_TAB *tabp, void *sym);
void *hsh_nextsym(HASH_TAB *tabp, void *i_last);
int hsh_ptab(HASH_TAB *tabp, void (*print)(void *, void *), void *param, int sort);
unsigned hash_add(unsigned char *name);					/* in hashadd.c */
unsigned hash_pjw(unsigned char *name);					/* in hashpjw.c */

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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