Merge from vendor branch PKGSRC:
[netbsd-mini2440.git] / include / search.h
blob9b64606367566f73b9d6d03a0d57436c9dd7fe99
1 /* $NetBSD: search.h,v 1.17 2005/03/22 20:13:42 kleink Exp $ */
3 /*
4 * Written by J.T. Conklin <jtc@NetBSD.org>
5 * Public domain.
6 */
8 #ifndef _SEARCH_H_
9 #define _SEARCH_H_
11 #include <sys/cdefs.h>
12 #include <machine/ansi.h>
14 #ifdef _BSD_SIZE_T_
15 typedef _BSD_SIZE_T_ size_t;
16 #undef _BSD_SIZE_T_
17 #endif
19 typedef struct entry {
20 char *key;
21 void *data;
22 } ENTRY;
24 typedef enum {
25 FIND, ENTER
26 } ACTION;
28 typedef enum {
29 preorder,
30 postorder,
31 endorder,
32 leaf
33 } VISIT;
35 #ifdef _SEARCH_PRIVATE
36 typedef struct node {
37 char *key;
38 struct node *llink, *rlink;
39 } node_t;
40 #endif
42 __BEGIN_DECLS
43 #ifndef __BSEARCH_DECLARED
44 #define __BSEARCH_DECLARED
45 /* also in stdlib.h */
46 void *bsearch(const void *, const void *, size_t, size_t,
47 int (*)(const void *, const void *));
48 #endif /* __BSEARCH_DECLARED */
49 int hcreate(size_t);
50 void hdestroy(void);
51 ENTRY *hsearch(ENTRY, ACTION);
53 void *lfind(const void *, const void *, size_t *, size_t,
54 int (*)(const void *, const void *));
55 void *lsearch(const void *, void *, size_t *, size_t,
56 int (*)(const void *, const void *));
57 void insque(void *, void *);
58 void remque(void *);
60 void *tdelete(const void * __restrict, void ** __restrict,
61 int (*)(const void *, const void *));
62 void *tfind(const void *, void * const *,
63 int (*)(const void *, const void *));
64 void *tsearch(const void *, void **,
65 int (*)(const void *, const void *));
66 void twalk(const void *, void (*)(const void *, VISIT, int));
67 __END_DECLS
69 #endif /* !_SEARCH_H_ */