Initial import from FreeBSD RELENG_4:
[dragonfly.git] / include / strhash.h
1 #ifndef _STRHASH_H_INCLUDE
2 #define _STRHASH_H_INCLUDE
3
4 /* $FreeBSD: src/include/strhash.h,v 1.3 1999/08/28 04:59:30 peter Exp $ */
5
6 /*
7  *
8  *                      Copyright 1990
9  *               Terry Jones & Jordan Hubbard
10  *
11  *                PCS Computer Systeme, GmbH.
12  *                   Munich, West Germany
13  *
14  *
15  *  All rights reserved.
16  *
17  *  This is unsupported software and is subject to change without notice.
18  *  the author makes no representations about the suitability of this software
19  *  for any purpose. It is supplied "as is" without express or implied
20  *  warranty.
21  *
22  *  Permission to use, copy, modify, and distribute this software and its
23  *  documentation for any purpose and without fee is hereby granted, provided
24  *  that the above copyright notice appear in all copies and that both that
25  *  copyright notice and this permission notice appear in supporting
26  *  documentation, and that the name of the author not be used in
27  *  advertising or publicity pertaining to distribution of the software
28  *  without specific, written prior permission.
29  *
30  */
31
32 /*
33  * This is the definition file for hash.c. The plunderer from down-under
34  * did the code, I just helped define the spec. That's why his name gets
35  * to go first.
36  */
37
38 #define HASH_SZ 97
39
40 typedef struct _node {
41     char *key;
42     void *data;
43     struct _node *next;
44 } hash_node;
45
46 typedef struct {
47     int size;
48     hash_node **buckets;
49 } hash_table;
50
51 hash_table *hash_create(int size);
52 void    hash_destroy(hash_table *table, char *key,
53                      void (*nukefunc)(char *k, void *d));
54 void    *hash_search(hash_table *table, char *key, void *datum,
55                      void (*replace_func)(void *d));
56 void    hash_traverse(hash_table *table,
57                       int (*func)(char *k, void *d, void *arg), void *arg);
58 void    hash_purge(hash_table *table, void (*purge_func)(char *k, void *d));
59
60 #ifdef HASH_STATS
61 extern void hash_stats();
62 #endif
63
64 #endif /* _STRHASH_H_INCLUDE */