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 /* Search for an entry matching the given KEY in the tree pointed to
26 by *ROOTP and insert a new element if not found. */
27 extern void *tsearch (const void *__key
, void **__rootp
,
28 __compar_fn_t __compar
);
30 /* Search for an entry matching the given KEY in the tree pointed to
31 by *ROOTP. If no matching entry is available return NULL. */
32 extern void *tfind (const void *__key
, void *const *__rootp
,
33 __compar_fn_t __compar
);
35 /* Remove the element matching KEY from the tree pointed to by *ROOTP. */
36 extern void *tdelete (const void *__restrict __key
,
37 void **__restrict __rootp
,
38 __compar_fn_t __compar
);
41 # define __ACTION_FN_T
42 typedef void (*__action_fn_t
) (const void *__nodep
, VISIT __value
,
46 /* Walk through the whole tree and call the ACTION callback for every node
48 extern void twalk (const void *__root
, __action_fn_t __action
);
51 /* Callback type for function to free a tree node. If the keys are atomic
52 data this function should do nothing. */
53 typedef void (*__free_fn_t
) (void *__nodep
);
55 /* Destroy the whole tree, call FREEFCT for each node or leaf. */
56 extern void tdestroy (void *__root
, __free_fn_t __freefct
);