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