1/*-
2 * Written by J.T. Conklin <jtc@netbsd.org>
3 * Public domain.
4 *
5 *	$NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
6 * $FreeBSD: src/include/search.h,v 1.10 2002/10/16 14:29:23 robert Exp $
7 */
8
9#ifndef _SEARCH_H_
10#define _SEARCH_H_
11
12#include <sys/cdefs.h>
13#include <_types.h>
14#include <sys/_types/_size_t.h>
15
16typedef	struct entry {
17	char	*key;
18	void	*data;
19} ENTRY;
20
21typedef	enum {
22	FIND, ENTER
23} ACTION;
24
25typedef	enum {
26	preorder,
27	postorder,
28	endorder,
29	leaf
30} VISIT;
31
32#ifdef _SEARCH_PRIVATE
33typedef	struct node {
34	char         *key;
35	struct node  *llink, *rlink;
36} node_t;
37
38struct que_elem {
39	struct que_elem *next;
40	struct que_elem *prev;
41};
42#endif
43
44__BEGIN_DECLS
45int	 hcreate(size_t);
46void	 hdestroy(void);
47ENTRY	*hsearch(ENTRY, ACTION);
48void	 insque(void *, void *);
49void	*lfind(const void *, const void *, size_t *, size_t,
50	    int (*)(const void *, const void *));
51void	*lsearch(const void *, void *, size_t *, size_t,
52	    int (*)(const void *, const void *));
53void	 remque(void *);
54void	*tdelete(const void * __restrict, void ** __restrict,
55	    int (*)(const void *, const void *));
56void	*tfind(const void *, void * const *,
57	    int (*)(const void *, const void *));
58void	*tsearch(const void *, void **, int (*)(const void *, const void *));
59void	 twalk(const void *, void (*)(const void *, VISIT, int));
60__END_DECLS
61
62#endif /* !_SEARCH_H_ */
63