]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/search.h
MFV r282150
[FreeBSD/FreeBSD.git] / include / search.h
1 /*-
2  * Written by J.T. Conklin <jtc@NetBSD.org>
3  * Public domain.
4  *
5  *      $NetBSD: search.h,v 1.16 2005/02/03 04:39:32 perry Exp $
6  * $FreeBSD$
7  */
8
9 #ifndef _SEARCH_H_
10 #define _SEARCH_H_
11
12 #include <sys/cdefs.h>
13 #include <sys/_types.h>
14
15 #ifndef _SIZE_T_DECLARED
16 typedef __size_t        size_t;
17 #define _SIZE_T_DECLARED
18 #endif
19
20 typedef struct entry {
21         char    *key;
22         void    *data;
23 } ENTRY;
24
25 typedef enum {
26         FIND, ENTER
27 } ACTION;
28
29 typedef enum {
30         preorder,
31         postorder,
32         endorder,
33         leaf
34 } VISIT;
35
36 #ifdef _SEARCH_PRIVATE
37 typedef struct node {
38         char         *key;
39         struct node  *llink, *rlink;
40 } node_t;
41
42 struct que_elem {
43         struct que_elem *next;
44         struct que_elem *prev;
45 };
46 #endif
47
48 #if __BSD_VISIBLE
49 struct _ENTRY;
50 struct hsearch_data {
51         struct _ENTRY *table;
52         size_t size;
53         size_t filled;
54 };
55 #endif
56
57 __BEGIN_DECLS
58 int      hcreate(size_t);
59 void     hdestroy(void);
60 ENTRY   *hsearch(ENTRY, ACTION);
61 void     insque(void *, void *);
62 void    *lfind(const void *, const void *, size_t *, size_t,
63             int (*)(const void *, const void *));
64 void    *lsearch(const void *, void *, size_t *, size_t,
65             int (*)(const void *, const void *));
66 void     remque(void *);
67 void    *tdelete(const void * __restrict, void ** __restrict,
68             int (*)(const void *, const void *));
69 void    *tfind(const void *, void * const *,
70             int (*)(const void *, const void *));
71 void    *tsearch(const void *, void **, int (*)(const void *, const void *));
72 void     twalk(const void *, void (*)(const void *, VISIT, int));
73
74 #if __BSD_VISIBLE
75 int      hcreate_r(size_t, struct hsearch_data *);
76 void     hdestroy_r(struct hsearch_data *);
77 int      hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
78 #endif
79
80 __END_DECLS
81
82 #endif /* !_SEARCH_H_ */