1 /* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ 2 /* $FreeBSD: src/include/search.h,v 1.3.2.1 2000/08/17 07:38:34 jhb Exp $ */ 3 /* $DragonFly: src/include/search.h,v 1.5 2003/11/15 19:28:42 asmodai Exp $ */ 4 5 /* 6 * Written by J.T. Conklin <jtc@netbsd.org> 7 * Public domain. 8 */ 9 10 #ifndef _SEARCH_H_ 11 #define _SEARCH_H_ 12 13 #include <sys/cdefs.h> 14 #include <machine/stdint.h> 15 16 #ifndef _SIZE_T_DECLARED 17 #define _SIZE_T_DECLARED 18 typedef __size_t size_t; 19 #endif 20 21 typedef struct entry { 22 char *key; 23 void *data; 24 } ENTRY; 25 26 typedef enum { 27 FIND, ENTER 28 } ACTION; 29 30 typedef enum { 31 preorder, 32 postorder, 33 endorder, 34 leaf 35 } VISIT; 36 37 #ifdef _SEARCH_PRIVATE 38 typedef struct node { 39 char *key; 40 struct node *llink, *rlink; 41 } node_t; 42 #endif 43 44 __BEGIN_DECLS 45 int hcreate (size_t); 46 void hdestroy (void); 47 ENTRY *hsearch (ENTRY, ACTION); 48 void *tdelete (const void *, void **, 49 int (*)(const void *, const void *)); 50 void *tfind (const void *, void **, 51 int (*)(const void *, const void *)); 52 void *tsearch (const void *, void **, 53 int (*)(const void *, const void *)); 54 void twalk (const void *, void (*)(const void *, VISIT, int)); 55 __END_DECLS 56 57 #endif /* !_SEARCH_H_ */ 58