1 /* $OpenBSD: search.h,v 1.3 1997/09/21 10:45:49 niklas 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 #include <sys/cdefs.h> 12 #include <machine/ansi.h> 13 14 #ifdef _BSD_SIZE_T_ 15 typedef _BSD_SIZE_T_ size_t; 16 #undef _BSD_SIZE_T_ 17 #endif 18 19 typedef struct entry { 20 char *key; 21 char *data; 22 } ENTRY; 23 24 typedef enum { 25 FIND, ENTER 26 } ACTION; 27 28 typedef enum { 29 preorder, 30 postorder, 31 endorder, 32 leaf 33 } VISIT; 34 35 __BEGIN_DECLS 36 extern void *bsearch __P((const void *, const void *, size_t, size_t, 37 int (*)(const void *, const void *))); 38 extern int hcreate __P((unsigned int)); 39 extern void hdestroy __P((void)); 40 extern ENTRY *hsearch __P((ENTRY, ACTION)); 41 42 extern void *lfind __P((const void *, const void *, size_t *, size_t, 43 int (*)(const void *, const void *))); 44 extern void *lsearch __P((const void *, const void *, size_t *, size_t, 45 int (*)(const void *, const void *))); 46 extern void insque __P((void *, void *)); 47 extern void remque __P((void *)); 48 49 extern void *tdelete __P((const void *, void **, 50 int (*)(const void *, const void *))); 51 extern void *tfind __P((const void *, void * const *, 52 int (*)(const void *, const void *))); 53 extern void *tsearch __P((const void *, void **, 54 int (*)(const void *, const void *))); 55 extern void twalk __P((const void *, void (*)(const void *, VISIT, int))); 56 __END_DECLS 57 58 #endif 59