Ben Cheng | 21eab51 | 2012-03-13 23:04:57 -0700 | [diff] [blame] | 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: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $ |
| 7 | */ |
| 8 | |
| 9 | #ifndef _SEARCH_H_ |
| 10 | #define _SEARCH_H_ |
| 11 | |
| 12 | #include <sys/cdefs.h> |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 13 | #include <sys/types.h> |
Ben Cheng | 21eab51 | 2012-03-13 23:04:57 -0700 | [diff] [blame] | 14 | |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 15 | typedef enum { |
Elliott Hughes | 5702c6f | 2017-08-31 17:27:05 -0700 | [diff] [blame^] | 16 | FIND, |
| 17 | ENTER |
| 18 | } ACTION; |
| 19 | |
| 20 | typedef struct entry { |
| 21 | char* key; |
| 22 | void* data; |
| 23 | } ENTRY; |
| 24 | |
| 25 | typedef enum { |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 26 | preorder, |
| 27 | postorder, |
| 28 | endorder, |
| 29 | leaf |
Ben Cheng | 21eab51 | 2012-03-13 23:04:57 -0700 | [diff] [blame] | 30 | } VISIT; |
| 31 | |
Elliott Hughes | 5702c6f | 2017-08-31 17:27:05 -0700 | [diff] [blame^] | 32 | #if defined(__USE_BSD) || defined(__USE_GNU) |
| 33 | struct hsearch_data { |
| 34 | struct __hsearch* __hsearch; |
| 35 | }; |
Ben Cheng | 21eab51 | 2012-03-13 23:04:57 -0700 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | __BEGIN_DECLS |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 39 | |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 40 | void insque(void* __element, void* __previous) __INTRODUCED_IN(21); |
| 41 | void remque(void* __element) __INTRODUCED_IN(21); |
Elliott Hughes | b902641 | 2014-07-23 16:02:26 -0700 | [diff] [blame] | 42 | |
Elliott Hughes | 5702c6f | 2017-08-31 17:27:05 -0700 | [diff] [blame^] | 43 | int hcreate(size_t) __INTRODUCED_IN_FUTURE; |
| 44 | void hdestroy(void) __INTRODUCED_IN_FUTURE; |
| 45 | ENTRY* hsearch(ENTRY, ACTION) __INTRODUCED_IN_FUTURE; |
| 46 | |
| 47 | #if defined(__USE_BSD) || defined(__USE_GNU) |
| 48 | int hcreate_r(size_t, struct hsearch_data*) __INTRODUCED_IN_FUTURE; |
| 49 | void hdestroy_r(struct hsearch_data*) __INTRODUCED_IN_FUTURE; |
| 50 | int hsearch_r(ENTRY, ACTION, ENTRY**, struct hsearch_data*) __INTRODUCED_IN_FUTURE; |
| 51 | #endif |
| 52 | |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 53 | void* lfind(const void* __key, const void* __base, size_t* __count, size_t __size, int (*__comparator)(const void*, const void*)) |
Josh Gao | 14adff1 | 2016-04-29 12:00:55 -0700 | [diff] [blame] | 54 | __INTRODUCED_IN(21); |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 55 | void* lsearch(const void* __key, void* __base, size_t* __count, size_t __size, int (*__comparator)(const void*, const void*)) |
Josh Gao | 14adff1 | 2016-04-29 12:00:55 -0700 | [diff] [blame] | 56 | __INTRODUCED_IN(21); |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 57 | |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 58 | void* tdelete(const void* __key, void** __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16); |
| 59 | void tdestroy(void* __root, void (*__free_fn)(void*)) __INTRODUCED_IN(16); |
| 60 | void* tfind(const void* __key, void* const* __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16); |
| 61 | void* tsearch(const void* __key, void** __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16); |
| 62 | void twalk(const void* __root, void (*__visitor)(const void*, VISIT, int)) __INTRODUCED_IN(21); |
Elliott Hughes | 7f3a272 | 2014-04-01 12:40:00 -0700 | [diff] [blame] | 63 | |
Ben Cheng | 21eab51 | 2012-03-13 23:04:57 -0700 | [diff] [blame] | 64 | __END_DECLS |
| 65 | |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 66 | #endif |