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: inthash.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.4 $ $Date: 2016/11/28 05:01:54 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * A simple hash table implementation for ints, contributed by John Stone, 00019 * derived from his ray tracer code. 00020 * NOTES: - this can only used for _positive_ data values (HASH_FAIL is -1) 00021 * - this code is slightly modified from the version in VMD 00022 * so that both, the string hash and the int hash can be used. 00023 ***************************************************************************/ 00024 #ifndef INTHASH_H 00025 #define INTHASH_H 00026 00028 typedef struct inthash_t { 00029 struct inthash_node_t **bucket; /* array of hash nodes */ 00030 int size; /* size of the array */ 00031 int entries; /* number of entries in table */ 00032 int downshift; /* shift cound, used in hash function */ 00033 int mask; /* used to select bits for hashing */ 00034 } inthash_t; 00035 00036 #define HASH_FAIL -1 00037 00038 #if defined(VMDPLUGIN_STATIC) 00039 #define VMDEXTERNSTATIC static 00040 #include "inthash.c" 00041 #else 00042 00043 #define VMDEXTERNSTATIC 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00050 void inthash_init(inthash_t *, int); 00051 00053 int inthash_lookup(const inthash_t *, int); 00054 00056 int inthash_insert(inthash_t *, int, int); 00057 00059 int inthash_delete(inthash_t *, int); 00060 00062 int inthash_entries(inthash_t *); 00063 00065 void inthash_destroy(inthash_t *); 00066 00068 char *inthash_stats(inthash_t *); 00069 00070 #ifdef __cplusplus 00071 } 00072 #endif 00073 00074 #endif 00075 00076 #endif