5702c6ff45
I'm unable to find a bug, but we've had requests for this internally once or twice (though I pointed those folks at the STL), and there's code we build for the host or in our bootloaders that would use this, and there's reasonable-looking FreeBSD implementation ready and waiting. Bug: N/A Test: ran tests Change-Id: I6ddee4b71bea4c22ed015debd31d3eaac4fcdd35
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
/*-
|
|
* Written by J.T. Conklin <jtc@netbsd.org>
|
|
* Public domain.
|
|
*
|
|
* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
|
|
* $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $
|
|
*/
|
|
|
|
#ifndef _SEARCH_H_
|
|
#define _SEARCH_H_
|
|
|
|
#include <sys/cdefs.h>
|
|
#include <sys/types.h>
|
|
|
|
typedef enum {
|
|
FIND,
|
|
ENTER
|
|
} ACTION;
|
|
|
|
typedef struct entry {
|
|
char* key;
|
|
void* data;
|
|
} ENTRY;
|
|
|
|
typedef enum {
|
|
preorder,
|
|
postorder,
|
|
endorder,
|
|
leaf
|
|
} VISIT;
|
|
|
|
#if defined(__USE_BSD) || defined(__USE_GNU)
|
|
struct hsearch_data {
|
|
struct __hsearch* __hsearch;
|
|
};
|
|
#endif
|
|
|
|
__BEGIN_DECLS
|
|
|
|
void insque(void* __element, void* __previous) __INTRODUCED_IN(21);
|
|
void remque(void* __element) __INTRODUCED_IN(21);
|
|
|
|
int hcreate(size_t) __INTRODUCED_IN_FUTURE;
|
|
void hdestroy(void) __INTRODUCED_IN_FUTURE;
|
|
ENTRY* hsearch(ENTRY, ACTION) __INTRODUCED_IN_FUTURE;
|
|
|
|
#if defined(__USE_BSD) || defined(__USE_GNU)
|
|
int hcreate_r(size_t, struct hsearch_data*) __INTRODUCED_IN_FUTURE;
|
|
void hdestroy_r(struct hsearch_data*) __INTRODUCED_IN_FUTURE;
|
|
int hsearch_r(ENTRY, ACTION, ENTRY**, struct hsearch_data*) __INTRODUCED_IN_FUTURE;
|
|
#endif
|
|
|
|
void* lfind(const void* __key, const void* __base, size_t* __count, size_t __size, int (*__comparator)(const void*, const void*))
|
|
__INTRODUCED_IN(21);
|
|
void* lsearch(const void* __key, void* __base, size_t* __count, size_t __size, int (*__comparator)(const void*, const void*))
|
|
__INTRODUCED_IN(21);
|
|
|
|
void* tdelete(const void* __key, void** __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16);
|
|
void tdestroy(void* __root, void (*__free_fn)(void*)) __INTRODUCED_IN(16);
|
|
void* tfind(const void* __key, void* const* __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16);
|
|
void* tsearch(const void* __key, void** __root_ptr, int (*__comparator)(const void*, const void*)) __INTRODUCED_IN(16);
|
|
void twalk(const void* __root, void (*__visitor)(const void*, VISIT, int)) __INTRODUCED_IN(21);
|
|
|
|
__END_DECLS
|
|
|
|
#endif
|