1 /* $OpenBSD: search.h,v 1.8 2006/01/06 18:53:04 millert Exp $ */ 2 /* $NetBSD: search.h,v 1.9 1995/08/08 21:14:45 jtc Exp $ */ 3 4 /* 5 * Written by J.T. Conklin <jtc@netbsd.org> 6 * Public domain. 7 */ 8 9 #ifndef _SEARCH_H_ 10 #define _SEARCH_H_ 11 12 #include <sys/cdefs.h> 13 #include <machine/_types.h> 14 15 #ifndef _SIZE_T_DEFINED_ 16 #define _SIZE_T_DEFINED_ 17 typedef __size_t size_t; 18 #endif 19 20 typedef struct entry { 21 char *key; 22 void *data; 23 } ENTRY; 24 25 typedef enum { 26 FIND, ENTER 27 } ACTION; 28 29 typedef enum { 30 preorder, 31 postorder, 32 endorder, 33 leaf 34 } VISIT; 35 36 __BEGIN_DECLS 37 void *bsearch(const void *, const void *, size_t, size_t, 38 int (*)(const void *, const void *)); 39 int hcreate(size_t); 40 void hdestroy(void); 41 ENTRY *hsearch(ENTRY, ACTION); 42 43 void *lfind(const void *, const void *, size_t *, size_t, 44 int (*)(const void *, const void *)); 45 void *lsearch(const void *, const void *, size_t *, size_t, 46 int (*)(const void *, const void *)); 47 void insque(void *, void *); 48 void remque(void *); 49 50 void *tdelete(const void *, void **, 51 int (*)(const void *, const void *)); 52 void *tfind(const void *, void * const *, 53 int (*)(const void *, const void *)); 54 void *tsearch(const void *, void **, 55 int (*)(const void *, const void *)); 56 void twalk(const void *, void (*)(const void *, VISIT, int)); 57 __END_DECLS 58 59 #endif /* !_SEARCH_H_ */ 60