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

📄 phtbl.h

📁 用C实现的在LINUX系统下的聊天程序.无需登录就可以下载
💻 H
字号:
/* phtbl.h - perfect hash table (pthread safe)                            *//*                                                                        *//* This program is free software; you can redistribute it and/or modify   *//* it under the terms of the GNU General Public License as published by   *//* the Free Software Foundation; either version 2, or (at your option)    *//* any later version.                                                     *//*                                                                        *//* This program is distributed in the hope that it will be useful,        *//* but WITHOUT ANY WARRANTY; without even the implied warranty of         *//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *//* GNU General Public License for more details.                           *//*                                                                        *//* You should have received a copy of the GNU General Public License      *//* along with this program; if not, write to the Free Software            *//* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA              *//* 02111-1307, USA.                                                       */#ifndef PHTBL_H#define PHTBL_H#include <pthread.h>#include <stdlib.h>/* Define a structure pthread safe */struct phtbl_item {  void *data;                                        /* data pointer      */  pthread_mutex_t guard;                             /* data guardian     */};/* Define a structure for open-addressed hash tables */typedef struct {  unsigned int positions;                            /* max positions     */  unsigned int (*hash) (const void *key);            /* aux. hash func    */  int (*solve) (const void *key1, const void *key2); /* solve collision   */  int (*match) (const void *key1, const void *key2); /* match function    */  void (*destroy) (void *data);                      /* free data         */  struct phtbl_item *table;                          /* hash table        */} phtbl_t;                                           /* perfect hash tbl  *//* positions can be any positive integer number */int phtbl_init(phtbl_t *htbl, unsigned int positions, unsigned int (*hash)(const void *key),   int (*match)(const void *key1, const void *key2), void (*destroy)(void *data),   int (*solve)(const void *key1, const void *key2));void phtbl_clean (phtbl_t *htbl);void phtbl_destroy(phtbl_t *htbl);int phtbl_insert(phtbl_t *htbl, void *data);void *phtbl_remove(phtbl_t *htbl, const void *data);void *phtbl_lookup(const phtbl_t *htbl, const void *data);#endif /* PHTBL_H */

⌨️ 快捷键说明

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