1 /* For use with hsearch(3). */
4 typedef int (*__compar_fn_t
) (const void *, const void *);
7 typedef __compar_fn_t comparison_fn_t
;
11 /* The tsearch routines are very interesting. They make many
12 assumptions about the compiler. It assumes that the first field
13 in node must be the "key" field, which points to the datum.
14 Everything depends on that. */
25 /* GCC 2.95 and later have "__restrict"; C99 compilers have
26 "restrict", and "configure" may have defined "restrict". */
28 # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
29 # if defined restrict || 199901L <= __STDC_VERSION__
30 # define __restrict restrict
37 /* Search for an entry matching the given KEY in the tree pointed to
38 by *ROOTP and insert a new element if not found. */
39 extern void *tsearch (const void *__key
, void **__rootp
,
40 __compar_fn_t __compar
);
42 /* Search for an entry matching the given KEY in the tree pointed to
43 by *ROOTP. If no matching entry is available return NULL. */
44 extern void *tfind (const void *__key
, void *const *__rootp
,
45 __compar_fn_t __compar
);
47 /* Remove the element matching KEY from the tree pointed to by *ROOTP. */
48 extern void *tdelete (const void *__restrict __key
,
49 void **__restrict __rootp
,
50 __compar_fn_t __compar
);
53 # define __ACTION_FN_T
54 typedef void (*__action_fn_t
) (const void *__nodep
, VISIT __value
,
58 /* Walk through the whole tree and call the ACTION callback for every node
60 extern void twalk (const void *__root
, __action_fn_t __action
);
63 /* Callback type for function to free a tree node. If the keys are atomic
64 data this function should do nothing. */
65 typedef void (*__free_fn_t
) (void *__nodep
);
67 /* Destroy the whole tree, call FREEFCT for each node or leaf. */
68 extern void tdestroy (void *__root
, __free_fn_t __freefct
);