1 /* $NetBSD: search.h,v 1.18 2005/07/06 15:47:15 drochner 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(const void *, const void *, size_t, size_t, 47 int (*)(const void *, const void *)); 48 #endif /* __BSEARCH_DECLARED */ 49 int hcreate(size_t); 50 void hdestroy(void); 51 ENTRY *hsearch(ENTRY, ACTION); 52 53 void *lfind(const void *, const void *, size_t *, size_t, 54 int (*)(const void *, const void *)); 55 void *lsearch(const void *, void *, size_t *, size_t, 56 int (*)(const void *, const void *)); 57 void insque(void *, void *); 58 void remque(void *); 59 60 void *tdelete(const void * __restrict, void ** __restrict, 61 int (*)(const void *, const void *)); 62 void *tfind(const void *, void * const *, 63 int (*)(const void *, const void *)); 64 void *tsearch(const void *, void **, 65 int (*)(const void *, const void *)); 66 void twalk(const void *, void (*)(const void *, VISIT, int)); 67 __END_DECLS 68 69 #endif /* !_SEARCH_H_ */ 70