#ifndef _SEARCH_H
#define _SEARCH_H 1
#include
#define __need_size_t
#include
__BEGIN_DECLS
#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
# ifdef __USE_GNU
struct qelem
{
struct qelem *q_forw;
struct qelem *q_back;
char q_data[1];
};
# endif
extern void insque (void *__elem, void *__prev) __THROW;
extern void remque (void *__elem) __THROW;
#endif
#ifndef __COMPAR_FN_T
# define __COMPAR_FN_T
typedef int (*__compar_fn_t) (__const void *, __const void *);
# ifdef __USE_GNU
typedef __compar_fn_t comparison_fn_t;
# endif
#endif
typedef enum
{
FIND,
ENTER
}
ACTION;
typedef struct entry
{
char *key;
void *data;
}
ENTRY;
struct _ENTRY;
extern ENTRY *hsearch (ENTRY __item, ACTION __action) __THROW;
extern int hcreate (size_t __nel) __THROW;
extern void hdestroy (void) __THROW;
#ifdef __USE_GNU
struct hsearch_data
{
struct _ENTRY *table;
unsigned int size;
unsigned int filled;
};
extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
struct hsearch_data *__htab) __THROW;
extern int hcreate_r (size_t __nel, struct hsearch_data *__htab) __THROW;
extern void hdestroy_r (struct hsearch_data *__htab) __THROW;
#endif
typedef enum
{
preorder,
postorder,
endorder,
leaf
}
VISIT;
extern void *tsearch (__const void *__key, void **__rootp,
__compar_fn_t __compar);
extern void *tfind (__const void *__key, void *__const *__rootp,
__compar_fn_t __compar);
extern void *tdelete (__const void *__restrict __key,
void **__restrict __rootp,
__compar_fn_t __compar);
#ifndef __ACTION_FN_T
# define __ACTION_FN_T
typedef void (*__action_fn_t) (__const void *__nodep, VISIT __value,
int __level);
#endif
extern void twalk (__const void *__root, __action_fn_t __action);
#ifdef __USE_GNU
typedef void (*__free_fn_t) (void *__nodep);
extern void tdestroy (void *__root, __free_fn_t __freefct);
#endif
extern void *lfind (__const void *__key, __const void *__base,
size_t *__nmemb, size_t __size, __compar_fn_t __compar);
extern void *lsearch (__const void *__key, void *__base,
size_t *__nmemb, size_t __size, __compar_fn_t __compar);
__END_DECLS
#endif
|