Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

strhash.h

00001 #ifndef _STRHASH_H_INCLUDE
00002 #define _STRHASH_H_INCLUDE
00003 
00004 /* $FreeBSD: src/include/strhash.h,v 1.3 1999/08/28 04:59:30 peter Exp $ */
00005 
00006 /*
00007  *
00008  *                      Copyright 1990
00009  *               Terry Jones & Jordan Hubbard
00010  *
00011  *                PCS Computer Systeme, GmbH.
00012  *                   Munich, West Germany
00013  *
00014  *
00015  *  All rights reserved.
00016  *
00017  *  This is unsupported software and is subject to change without notice.
00018  *  the author makes no representations about the suitability of this software
00019  *  for any purpose. It is supplied "as is" without express or implied
00020  *  warranty.
00021  *
00022  *  Permission to use, copy, modify, and distribute this software and its
00023  *  documentation for any purpose and without fee is hereby granted, provided
00024  *  that the above copyright notice appear in all copies and that both that
00025  *  copyright notice and this permission notice appear in supporting
00026  *  documentation, and that the name of the author not be used in
00027  *  advertising or publicity pertaining to distribution of the software
00028  *  without specific, written prior permission.
00029  *
00030  */
00031 
00032 /*
00033  * This is the definition file for hash.c. The plunderer from down-under
00034  * did the code, I just helped define the spec. That's why his name gets
00035  * to go first.
00036  */
00037 
00038 #define HASH_SZ 97
00039 
00040 typedef struct _node {
00041     char *key;
00042     void *data;
00043     struct _node *next;
00044 } hash_node;
00045 
00046 typedef struct {
00047     int size;
00048     hash_node **buckets;
00049 } hash_table;
00050 
00051 hash_table *hash_create(int size);
00052 void    hash_destroy(hash_table *table, char *key,
00053                      void (*nukefunc)(char *k, void *d));
00054 void    *hash_search(hash_table *table, char *key, void *datum,
00055                      void (*replace_func)(void *d));
00056 void    hash_traverse(hash_table *table,
00057                       int (*func)(char *k, void *d, void *arg), void *arg);
00058 void    hash_purge(hash_table *table, void (*purge_func)(char *k, void *d));
00059 
00060 #ifdef HASH_STATS
00061 extern void hash_stats();
00062 #endif
00063 
00064 #endif /* _STRHASH_H_INCLUDE */