master
1/*-
2 * Written by J.T. Conklin <jtc@netbsd.org>
3 * Public domain.
4 *
5 * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
6 * $FreeBSD: src/include/search.h,v 1.10 2002/10/16 14:29:23 robert Exp $
7 */
8
9#ifndef _SEARCH_H_
10#define _SEARCH_H_
11
12#include <sys/cdefs.h>
13#include <_bounds.h>
14#include <_types.h>
15#include <sys/_types/_size_t.h>
16
17_LIBC_SINGLE_BY_DEFAULT()
18
19typedef struct entry {
20 char *_LIBC_CSTR key;
21 void *data;
22} ENTRY;
23
24typedef enum {
25 FIND, ENTER
26} ACTION;
27
28typedef enum {
29 preorder,
30 postorder,
31 endorder,
32 leaf
33} VISIT;
34
35#ifdef _SEARCH_PRIVATE
36typedef struct node {
37 char *_LIBC_CSTR key;
38 struct node *llink, *rlink;
39} node_t;
40
41struct que_elem {
42 struct que_elem *next;
43 struct que_elem *prev;
44};
45#endif
46
47__BEGIN_DECLS
48int hcreate(size_t);
49void hdestroy(void);
50ENTRY *hsearch(ENTRY, ACTION);
51void insque(void *, void *);
52void *lfind(const void *, const void *_LIBC_UNSAFE_INDEXABLE, size_t *, size_t,
53 int (*)(const void *, const void *));
54void *lsearch(const void *, void *, size_t *_LIBC_UNSAFE_INDEXABLE, size_t,
55 int (*)(const void *, const void *));
56void remque(void *);
57void *tdelete(const void * __restrict, void ** __restrict,
58 int (*)(const void *, const void *));
59void *tfind(const void *, void * const *,
60 int (*)(const void *, const void *));
61void *tsearch(const void *, void **, int (*)(const void *, const void *));
62void twalk(const void *, void (*)(const void *, VISIT, int));
63__END_DECLS
64
65#endif /* !_SEARCH_H_ */