Rev 4874 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
1 | /* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ |
1 | /* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ |
2 | /* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ |
2 | /* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ |
3 | 3 | ||
4 | /* |
4 | /* |
5 | * Written by J.T. Conklin |
5 | * Written by J.T. Conklin |
6 | * Public domain. |
6 | * Public domain. |
7 | */ |
7 | */ |
8 | 8 | ||
9 | #ifndef _SEARCH_H_ |
9 | #ifndef _SEARCH_H_ |
10 | #define _SEARCH_H_ |
10 | #define _SEARCH_H_ |
11 | 11 | ||
12 | #include |
12 | #include |
13 | #include |
13 | #include |
14 | #include |
14 | #include |
15 | 15 | ||
16 | typedef struct entry { |
16 | typedef struct entry { |
17 | char *key; |
17 | char *key; |
18 | void *data; |
18 | void *data; |
19 | } ENTRY; |
19 | } ENTRY; |
20 | 20 | ||
21 | typedef enum { |
21 | typedef enum { |
22 | FIND, ENTER |
22 | FIND, ENTER |
23 | } ACTION; |
23 | } ACTION; |
24 | 24 | ||
25 | typedef enum { |
25 | typedef enum { |
26 | preorder, |
26 | preorder, |
27 | postorder, |
27 | postorder, |
28 | endorder, |
28 | endorder, |
29 | leaf |
29 | leaf |
30 | } VISIT; |
30 | } VISIT; |
31 | 31 | ||
32 | #ifdef _SEARCH_PRIVATE |
32 | #ifdef _SEARCH_PRIVATE |
33 | typedef struct node { |
33 | typedef struct node { |
34 | char *key; |
34 | char *key; |
35 | struct node *llink, *rlink; |
35 | struct node *llink, *rlink; |
36 | } node_t; |
36 | } node_t; |
37 | #endif |
37 | #endif |
38 | 38 | ||
39 | struct hsearch_data |
39 | struct hsearch_data |
40 | { |
40 | { |
41 | struct internal_head *htable; |
41 | struct internal_head *htable; |
42 | size_t htablesize; |
42 | size_t htablesize; |
43 | }; |
43 | }; |
- | 44 | ||
- | 45 | #ifndef __compar_fn_t_defined |
|
- | 46 | #define __compar_fn_t_defined |
|
- | 47 | typedef int (*__compar_fn_t) (const void *, const void *); |
|
- | 48 | #endif |
|
44 | 49 | ||
45 | __BEGIN_DECLS |
50 | __BEGIN_DECLS |
46 | int hcreate(size_t); |
51 | int hcreate(size_t); |
47 | void hdestroy(void); |
52 | void hdestroy(void); |
48 | ENTRY *hsearch(ENTRY, ACTION); |
53 | ENTRY *hsearch(ENTRY, ACTION); |
49 | int hcreate_r(size_t, struct hsearch_data *); |
54 | int hcreate_r(size_t, struct hsearch_data *); |
50 | void hdestroy_r(struct hsearch_data *); |
55 | void hdestroy_r(struct hsearch_data *); |
51 | int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); |
56 | int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); |
52 | void *tdelete(const void *, void **, int (*)(const void *, const void *)); |
57 | void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t); |
53 | void tdestroy (void *, void (*)(void *)); |
58 | void tdestroy (void *, void (*)(void *)); |
54 | void *tfind(const void *, void **, int (*)(const void *, const void *)); |
59 | void *tfind(const void *, void **, __compar_fn_t); |
55 | void *tsearch(const void *, void **, int (*)(const void *, const void *)); |
60 | void *tsearch(const void *, void **, __compar_fn_t); |
56 | void twalk(const void *, void (*)(const void *, VISIT, int)); |
61 | void twalk(const void *, void (*)(const void *, VISIT, int)); |
57 | __END_DECLS |
62 | __END_DECLS |
58 | 63 | ||
59 | #endif /* !_SEARCH_H_ */ |
64 | #endif /* !_SEARCH_H_ */ |