search.h revision 1.13 1 /* $NetBSD: search.h,v 1.13 2000/06/13 01:21:53 simonb 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 #ifdef _SEARCH_PRIVATE
36 typedef struct node {
37 char *key;
38 struct node *llink, *rlink;
39 } node_t;
40 #endif
41
42 __BEGIN_DECLS
43 void *bsearch __P((const void *, const void *, size_t, size_t,
44 int (*)(const void *, const void *)));
45 int hcreate __P((size_t));
46 void hdestroy __P((void));
47 ENTRY *hsearch __P((ENTRY, ACTION));
48
49 void *lfind __P((const void *, const void *, size_t *, size_t,
50 int (*)(const void *, const void *)));
51 void *lsearch __P((const void *, const void *, size_t *, size_t,
52 int (*)(const void *, const void *)));
53 void insque __P((void *, void *));
54 void remque __P((void *));
55
56 void *tdelete __P((const void *, void **,
57 int (*)(const void *, const void *)));
58 void *tfind __P((const void *, void **,
59 int (*)(const void *, const void *)));
60 void *tsearch __P((const void *, void **,
61 int (*)(const void *, const void *)));
62 void twalk __P((const void *, void (*)(const void *, VISIT, int)));
63 __END_DECLS
64
65 #endif /* !_SEARCH_H_ */
66