sync
[bitrig.git] / include / search.h
blob1917dd0d283942e057c632ae397f72e0dba1c5a9
1 /* $OpenBSD: search.h,v 1.9 2012/07/10 11:44:55 guenther Exp $ */
2 /* $NetBSD: search.h,v 1.9 1995/08/08 21:14:45 jtc Exp $ */
4 /*
5 * Written by J.T. Conklin <jtc@netbsd.org>
6 * Public domain.
7 */
9 #ifndef _SEARCH_H_
10 #define _SEARCH_H_
12 #include <sys/cdefs.h>
13 #include <machine/_types.h>
15 #ifndef _SIZE_T_DEFINED_
16 #define _SIZE_T_DEFINED_
17 typedef __size_t size_t;
18 #endif
20 typedef struct entry {
21 char *key;
22 void *data;
23 } ENTRY;
25 typedef enum {
26 FIND, ENTER
27 } ACTION;
29 typedef enum {
30 preorder,
31 postorder,
32 endorder,
33 leaf
34 } VISIT;
36 __BEGIN_DECLS
37 int hcreate(size_t);
38 void hdestroy(void);
39 ENTRY *hsearch(ENTRY, ACTION);
41 void *lfind(const void *, const void *, size_t *, size_t,
42 int (*)(const void *, const void *));
43 void *lsearch(const void *, const void *, size_t *, size_t,
44 int (*)(const void *, const void *));
45 void insque(void *, void *);
46 void remque(void *);
48 void *tdelete(const void * __restrict, void ** __restrict,
49 int (*)(const void *, const void *));
50 void *tfind(const void *, void * const *,
51 int (*)(const void *, const void *));
52 void *tsearch(const void *, void **,
53 int (*)(const void *, const void *));
54 void twalk(const void *, void (*)(const void *, VISIT, int));
55 __END_DECLS
57 #endif /* !_SEARCH_H_ */