1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/***************************************************************************
*cr
*cr (C) Copyright 1995-2016 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************************/
/***************************************************************************
* RCS INFORMATION:
*
* $RCSfile: hash.h,v $
* $Author: johns $ $Locker: $ $State: Exp $
* $Revision: 1.9 $ $Date: 2016/11/28 05:01:54 $
*
***************************************************************************
* DESCRIPTION:
* A simple hash table implementation for strings, contributed by John Stone,
* derived from his ray tracer code.
***************************************************************************/
#ifndef HASH_H
#define HASH_H
/** hash table top level data structure */
typedef struct hash_t {
struct hash_node_t **bucket; /* array of hash nodes */
int size; /* size of the array */
int entries; /* number of entries in table */
int downshift; /* shift count, used in hash function */
int mask; /* used to select bits for hashing */
} hash_t;
#define HASH_FAIL -1
#if defined(VMDPLUGIN_STATIC)
#define VMDEXTERNSTATIC static
#include "hash.c"
#else
#define VMDEXTERNSTATIC
#ifdef __cplusplus
extern "C" {
#endif
/** initialize hash table for first use */
void hash_init(hash_t *, int);
/** lookup a string key in the hash table returning its integer key */
int hash_lookup (const hash_t *, const char *);
/** insert a string into the hash table, along with an integer key */
int hash_insert (hash_t *, const char *, int);
/** delete an string from the hash table, given its string name */
int hash_delete (hash_t *, const char *);
/** return the number of entries in the has table */
int hash_entries(hash_t *);
/** destroy the hash table completely, deallocate memory */
void hash_destroy(hash_t *);
/** print hash table vital stats */
char *hash_stats (hash_t *);
#ifdef __cplusplus
}
#endif
#endif
#endif
|