00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2016 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: hash.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.9 $ $Date: 2016/11/28 05:01:54 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * A simple hash table implementation for strings, contributed by John Stone, 00019 * derived from his ray tracer code. 00020 ***************************************************************************/ 00021 #ifndef HASH_H 00022 #define HASH_H 00023 00025 typedef struct hash_t { 00026 struct hash_node_t **bucket; /* array of hash nodes */ 00027 int size; /* size of the array */ 00028 int entries; /* number of entries in table */ 00029 int downshift; /* shift count, used in hash function */ 00030 int mask; /* used to select bits for hashing */ 00031 } hash_t; 00032 00033 #define HASH_FAIL -1 00034 00035 #if defined(VMDPLUGIN_STATIC) 00036 #define VMDEXTERNSTATIC static 00037 #include "hash.c" 00038 #else 00039 00040 #define VMDEXTERNSTATIC 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00047 void hash_init(hash_t *, int); 00048 00050 int hash_lookup (const hash_t *, const char *); 00051 00053 int hash_insert (hash_t *, const char *, int); 00054 00056 int hash_delete (hash_t *, const char *); 00057 00059 int hash_entries(hash_t *); 00060 00062 void hash_destroy(hash_t *); 00063 00065 char *hash_stats (hash_t *); 00066 00067 #ifdef __cplusplus 00068 } 00069 #endif 00070 00071 #endif 00072 00073 #endif