1 /* $NetBSD: search.h,v 1.14 2000/12/20 18:35:21 christos Exp $ */ 2 3 /* 4 * Written by J.T. Conklin <jtc@netbsd.org> 5 * Public domain. 6 */ 7 8 #ifndef _SEARCH_H_ 9 #define _SEARCH_H_ 10 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 void *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 #ifdef _SEARCH_PRIVATE 36 typedef struct node { 37 char *key; 38 struct node *llink, *rlink; 39 } node_t; 40 #endif 41 42 __BEGIN_DECLS 43 #ifndef __BSEARCH_DECLARED 44 #define __BSEARCH_DECLARED 45 /* also in stdlib.h */ 46 void *bsearch __P((const void *, const void *, size_t, size_t, 47 int (*)(const void *, const void *))); 48 #endif /* __BSEARCH_DECLARED */ 49 int hcreate __P((size_t)); 50 void hdestroy __P((void)); 51 ENTRY *hsearch __P((ENTRY, ACTION)); 52 53 void *lfind __P((const void *, const void *, size_t *, size_t, 54 int (*)(const void *, const void *))); 55 void *lsearch __P((const void *, const void *, size_t *, size_t, 56 int (*)(const void *, const void *))); 57 void insque __P((void *, void *)); 58 void remque __P((void *)); 59 60 void *tdelete __P((const void *, void **, 61 int (*)(const void *, const void *))); 62 void *tfind __P((const void *, void **, 63 int (*)(const void *, const void *))); 64 void *tsearch __P((const void *, void **, 65 int (*)(const void *, const void *))); 66 void twalk __P((const void *, void (*)(const void *, VISIT, int))); 67 __END_DECLS 68 69 #endif /* !_SEARCH_H_ */ 70