123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #ifndef _SEARCH_H
- #define _SEARCH_H 1
- #include <features.h>
- #define __need_size_t
- #include <stddef.h>
- __BEGIN_DECLS
- #if defined __USE_MISC || 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
|