search.h revision 1.11 1 /* $NetBSD: search.h,v 1.11 1999/02/16 18:23:01 kleink Exp $ */
2
3 /*
4 * Written by J.T. Conklin <jtc (at) netbsd.org>
5 * Public domain.
6 */
7
8 #ifndef _SEARCH_H_
9 #define _SEARCH_H_
10
11 #include <sys/cdefs.h>
12 #include <machine/ansi.h>
13
14 #ifdef _BSD_SIZE_T_
15 typedef _BSD_SIZE_T_ size_t;
16 #undef _BSD_SIZE_T_
17 #endif
18
19 typedef struct entry {
20 char *key;
21 void *data;
22 } ENTRY;
23
24 typedef enum {
25 FIND, ENTER
26 } ACTION;
27
28 typedef enum {
29 preorder,
30 postorder,
31 endorder,
32 leaf
33 } VISIT;
34
35 __BEGIN_DECLS
36 extern void *bsearch __P((const void *, const void *, size_t, size_t,
37 int (*)(const void *, const void *)));
38 extern int hcreate __P((size_t));
39 extern void hdestroy __P((void));
40 extern ENTRY *hsearch __P((ENTRY, ACTION));
41
42 extern void *lfind __P((const void *, const void *, size_t *, size_t,
43 int (*)(const void *, const void *)));
44 extern void *lsearch __P((const void *, const void *, size_t *, size_t,
45 int (*)(const void *, const void *)));
46 extern void insque __P((void *, void *));
47 extern void remque __P((void *));
48
49 extern void *tdelete __P((const void *, void **,
50 int (*)(const void *, const void *)));
51 extern void *tfind __P((const void *, void **,
52 int (*)(const void *, const void *)));
53 extern void *tsearch __P((const void *, void **,
54 int (*)(const void *, const void *)));
55 extern void twalk __P((const void *, void (*)(const void *, VISIT, int)));
56 __END_DECLS
57
58 #endif /* !_SEARCH_H_ */
59