]> git.saurik.com Git - apple/libc.git/blob - include/search.h
aa21d8b75725b2b99cd288ee3103df5eab038730
[apple/libc.git] / include / search.h
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 <sys/types.h>
14
15 typedef struct entry {
16 char *key;
17 void *data;
18 } ENTRY;
19
20 typedef enum {
21 FIND, ENTER
22 } ACTION;
23
24 typedef enum {
25 preorder,
26 postorder,
27 endorder,
28 leaf
29 } VISIT;
30
31 #ifdef _SEARCH_PRIVATE
32 typedef struct node {
33 char *key;
34 struct node *llink, *rlink;
35 } node_t;
36
37 struct que_elem {
38 struct que_elem *next;
39 struct que_elem *prev;
40 };
41 #endif
42
43 __BEGIN_DECLS
44 int hcreate(size_t);
45 void hdestroy(void);
46 ENTRY *hsearch(ENTRY, ACTION);
47 void insque(void *, void *);
48 void *lfind(const void *, const void *, size_t *, size_t,
49 int (*)(const void *, const void *));
50 void *lsearch(const void *, void *, size_t *, size_t,
51 int (*)(const void *, const void *));
52 void remque(void *);
53 void *tdelete(const void * __restrict, void ** __restrict,
54 int (*)(const void *, const void *));
55 void *tfind(const void *, void * const *,
56 int (*)(const void *, const void *));
57 void *tsearch(const void *, void **, int (*)(const void *, const void *));
58 void twalk(const void *, void (*)(const void *, VISIT, int));
59 __END_DECLS
60
61 #endif /* !_SEARCH_H_ */