Home | History | Annotate | Line # | Download | only in include
search.h revision 1.17
      1  1.17    kleink /*	$NetBSD: search.h,v 1.17 2005/03/22 20:13:42 kleink Exp $	*/
      2   1.6       cgd 
      3   1.1       jtc /*
      4  1.15      salo  * Written by J.T. Conklin <jtc (at) NetBSD.org>
      5   1.7       jtc  * Public domain.
      6   1.1       jtc  */
      7   1.1       jtc 
      8   1.1       jtc #ifndef _SEARCH_H_
      9   1.1       jtc #define _SEARCH_H_
     10  1.11    kleink 
     11   1.2       jtc #include <sys/cdefs.h>
     12   1.2       jtc #include <machine/ansi.h>
     13   1.1       jtc 
     14   1.5       cgd #ifdef	_BSD_SIZE_T_
     15   1.5       cgd typedef	_BSD_SIZE_T_	size_t;
     16   1.5       cgd #undef	_BSD_SIZE_T_
     17   1.2       jtc #endif
     18   1.1       jtc 
     19   1.9       jtc typedef struct entry {
     20   1.9       jtc 	char *key;
     21  1.11    kleink 	void *data;
     22   1.9       jtc } ENTRY;
     23   1.9       jtc 
     24   1.9       jtc typedef enum {
     25   1.9       jtc 	FIND, ENTER
     26   1.9       jtc } ACTION;
     27   1.9       jtc 
     28   1.8       jtc typedef enum {
     29   1.8       jtc 	preorder,
     30   1.8       jtc 	postorder,
     31   1.8       jtc 	endorder,
     32   1.8       jtc 	leaf
     33   1.8       jtc } VISIT;
     34  1.12  christos 
     35  1.12  christos #ifdef _SEARCH_PRIVATE
     36  1.12  christos typedef struct node {
     37  1.12  christos 	char         *key;
     38  1.12  christos 	struct node  *llink, *rlink;
     39  1.12  christos } node_t;
     40  1.12  christos #endif
     41   1.8       jtc 
     42   1.1       jtc __BEGIN_DECLS
     43  1.14  christos #ifndef __BSEARCH_DECLARED
     44  1.14  christos #define __BSEARCH_DECLARED
     45  1.14  christos /* also in stdlib.h */
     46  1.16     perry void	*bsearch(const void *, const void *, size_t, size_t,
     47  1.16     perry 		      int (*)(const void *, const void *));
     48  1.14  christos #endif /* __BSEARCH_DECLARED */
     49  1.16     perry int	 hcreate(size_t);
     50  1.16     perry void	 hdestroy(void);
     51  1.16     perry ENTRY	*hsearch(ENTRY, ACTION);
     52  1.16     perry 
     53  1.16     perry void	*lfind(const void *, const void *, size_t *, size_t,
     54  1.16     perry 		      int (*)(const void *, const void *));
     55  1.16     perry void	*lsearch(const void *, const void *, size_t *, size_t,
     56  1.16     perry 		      int (*)(const void *, const void *));
     57  1.16     perry void	 insque(void *, void *);
     58  1.16     perry void	 remque(void *);
     59  1.16     perry 
     60  1.17    kleink void	*tdelete(const void * __restrict, void ** __restrict,
     61  1.16     perry 		      int (*)(const void *, const void *));
     62  1.17    kleink void	*tfind(const void *, void * const *,
     63  1.16     perry 		      int (*)(const void *, const void *));
     64  1.16     perry void	*tsearch(const void *, void **,
     65  1.16     perry 		      int (*)(const void *, const void *));
     66  1.17    kleink void	 twalk(const void *, void (*)(const void *, VISIT, int));
     67   1.1       jtc __END_DECLS
     68   1.1       jtc 
     69  1.11    kleink #endif /* !_SEARCH_H_ */
     70