diff options
Diffstat (limited to 'system/include/libc/search.h')
-rw-r--r-- | system/include/libc/search.h | 88 |
1 files changed, 40 insertions, 48 deletions
diff --git a/system/include/libc/search.h b/system/include/libc/search.h index c78ce184..ebfe08a2 100644 --- a/system/include/libc/search.h +++ b/system/include/libc/search.h @@ -1,59 +1,51 @@ -/* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ -/* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ +#ifndef _SEARCH_H +#define _SEARCH_H -/* - * Written by J.T. Conklin <jtc@netbsd.org> - * Public domain. - */ +#ifdef __cplusplus +extern "C" { +#endif + +#include <features.h> -#ifndef _SEARCH_H_ -#define _SEARCH_H_ +#define __NEED_size_t +#include <bits/alltypes.h> -#include <sys/cdefs.h> -#include <machine/ansi.h> -#include <sys/types.h> +typedef enum { FIND, ENTER } ACTION; +typedef enum { preorder, postorder, endorder, leaf } VISIT; -typedef struct entry { +typedef struct { char *key; void *data; } ENTRY; -typedef enum { - FIND, ENTER -} ACTION; - -typedef enum { - preorder, - postorder, - endorder, - leaf -} VISIT; - -#ifdef _SEARCH_PRIVATE -typedef struct node { - char *key; - struct node *llink, *rlink; -} node_t; -#endif +int hcreate(size_t); +void hdestroy(void); +ENTRY *hsearch(ENTRY, ACTION); + +void insque(void *, void *); +void remque(void *); + +void *lsearch(const void *, void *, size_t *, size_t, + int (*)(const void *, const void *)); +void *lfind(const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *)); + +void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *)); +void *tfind(const void *, void *const *, int(*)(const void *, const void *)); +void *tsearch(const void *, void **, int (*)(const void *, const void *)); +void twalk(const void *, void (*)(const void *, VISIT, int)); -struct hsearch_data -{ - struct internal_head *htable; - size_t htablesize; +#ifdef _GNU_SOURCE +struct qelem { + struct qelem *q_forw, *q_back; + char q_data[1]; }; -__BEGIN_DECLS -int hcreate(size_t); -void hdestroy(void); -ENTRY *hsearch(ENTRY, ACTION); -int hcreate_r(size_t, struct hsearch_data *); -void hdestroy_r(struct hsearch_data *); -int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); -void *tdelete(const void *, void **, int (*)(const void *, const void *)); -void tdestroy (void *, void (*)(void *)); -void *tfind(const void *, void **, int (*)(const void *, const void *)); -void *tsearch(const void *, void **, int (*)(const void *, const void *)); -void twalk(const void *, void (*)(const void *, VISIT, int)); -__END_DECLS - -#endif /* !_SEARCH_H_ */ +void tdestroy(void *, void (*)(void *)); +#endif + +#ifdef __cplusplus +} +#endif + +#endif |