search.h revision 62684
1/*	$NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $	*/
2/* $FreeBSD: head/include/search.h 62684 2000-07-06 20:04:34Z alfred $ */
3
4/*
5 * Written by J.T. Conklin <jtc@netbsd.org>
6 * Public domain.
7 */
8
9#ifndef _SEARCH_H_
10#define _SEARCH_H_
11
12#include <sys/cdefs.h>
13#include <machine/ansi.h>
14
15#ifdef	_BSD_SIZE_T_
16typedef	_BSD_SIZE_T_	size_t;
17#undef	_BSD_SIZE_T_
18#endif
19
20typedef struct entry {
21	char *key;
22	void *data;
23} ENTRY;
24
25typedef enum {
26	FIND, ENTER
27} ACTION;
28
29typedef enum {
30	preorder,
31	postorder,
32	endorder,
33	leaf
34} VISIT;
35
36#ifdef _SEARCH_PRIVATE
37typedef struct node {
38	char         *key;
39	struct node  *llink, *rlink;
40} node_t;
41#endif
42
43__BEGIN_DECLS
44/* stdlib.h
45void	*bsearch __P((const void *, const void *, size_t, size_t,
46		      int (*)(const void *, const void *)));
47 */
48int	 hcreate __P((size_t));
49void	 hdestroy __P((void));
50ENTRY	*hsearch __P((ENTRY, ACTION));
51/* depricated interfaces (in libcompat)
52void	*lfind __P((const void *, const void *, size_t *, size_t,
53		      int (*)(const void *, const void *)));
54void	*lsearch __P((const void *, const void *, size_t *, size_t,
55		      int (*)(const void *, const void *)));
56void	 insque __P((void *, void *));
57void	 remque __P((void *));
58 */
59
60void	*tdelete __P((const void *, void **,
61		      int (*)(const void *, const void *)));
62void	*tfind __P((const void *, void **,
63		      int (*)(const void *, const void *)));
64void	*tsearch __P((const void *, void **,
65		      int (*)(const void *, const void *)));
66void      twalk __P((const void *, void (*)(const void *, VISIT, int)));
67__END_DECLS
68
69#endif /* !_SEARCH_H_ */
70