search.h 1.3 KB

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