search.h revision 308091
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: stable/10/include/search.h 308091 2016-10-29 15:04:24Z ed $ 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 16typedef __size_t size_t; 17#define _SIZE_T_DECLARED 18#endif 19 20typedef struct entry { 21 char *key; 22 void *data; 23} ENTRY; 24 25typedef enum { 26 FIND, ENTER 27} ACTION; 28 29typedef enum { 30 preorder, 31 postorder, 32 endorder, 33 leaf 34} VISIT; 35 36#ifdef _SEARCH_PRIVATE 37typedef struct node { 38 char *key; 39 struct node *llink, *rlink; 40} node_t; 41 42struct que_elem { 43 struct que_elem *next; 44 struct que_elem *prev; 45}; 46#else 47typedef void posix_tnode; 48#endif 49 50__BEGIN_DECLS 51int hcreate(size_t); 52void hdestroy(void); 53ENTRY *hsearch(ENTRY, ACTION); 54void insque(void *, void *); 55void *lfind(const void *, const void *, size_t *, size_t, 56 int (*)(const void *, const void *)); 57void *lsearch(const void *, void *, size_t *, size_t, 58 int (*)(const void *, const void *)); 59void remque(void *); 60void *tdelete(const void * __restrict, void ** __restrict, 61 int (*)(const void *, const void *)); 62void *tfind(const void *, void * const *, 63 int (*)(const void *, const void *)); 64void *tsearch(const void *, void **, int (*)(const void *, const void *)); 65void twalk(const void *, void (*)(const void *, VISIT, int)); 66__END_DECLS 67 68#endif /* !_SEARCH_H_ */ 69