1#ifndef _SEARCH_H 2#define _SEARCH_H 3 4#ifdef __cplusplus 5extern "C" { 6#endif 7 8#include <features.h> 9 10#define __NEED_size_t 11#include <bits/alltypes.h> 12 13typedef enum { FIND, ENTER } ACTION; 14typedef enum { preorder, postorder, endorder, leaf } VISIT; 15 16typedef struct entry { 17 char *key; 18 void *data; 19} ENTRY; 20 21int hcreate(size_t); 22void hdestroy(void); 23ENTRY *hsearch(ENTRY, ACTION); 24 25#ifdef _GNU_SOURCE 26struct hsearch_data { 27 struct __tab *__tab; 28 unsigned int __unused1; 29 unsigned int __unused2; 30}; 31 32int hcreate_r(size_t, struct hsearch_data *); 33void hdestroy_r(struct hsearch_data *); 34int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); 35#endif 36 37void insque(void *, void *); 38void remque(void *); 39 40void *lsearch(const void *, void *, size_t *, size_t, 41 int (*)(const void *, const void *)); 42void *lfind(const void *, const void *, size_t *, size_t, 43 int (*)(const void *, const void *)); 44 45void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *)); 46void *tfind(const void *, void *const *, int(*)(const void *, const void *)); 47void *tsearch(const void *, void **, int (*)(const void *, const void *)); 48void twalk(const void *, void (*)(const void *, VISIT, int)); 49 50#ifdef _GNU_SOURCE 51struct qelem { 52 struct qelem *q_forw, *q_back; 53 char q_data[1]; 54}; 55 56void tdestroy(void *, void (*)(void *)); 57#endif 58 59#ifdef __cplusplus 60} 61#endif 62 63#endif 64