order: Module for comparison callbacks
Many common algorithms take a callback for comparing items - effectively
giving the items a user defined order.
For example, the standard library qsort() and bsearch() routines take such
a callback. The ccan/avl module takes an identical one. The ccan/asort
and ccan/asearch modules use a different variant: their callback takes an
additional context parameter, and is also typed via use of macros and
typesafe_cb.
This module provides helper types and macros for easily declaring any of
the common variants on comparison functions: the 2-parameter untyped form
(as used by qsort), the 3-parameter untyped form (used by the asort back
end) and the 3-parameter typed form (used by the asort front end). It
provides a wrapper macro for doing the typesafe_cb conversion from
3-parameter typed to 3-parameter untyped.
It also provides a container struct to describe both a comparison callback
and a context value as a single structure. This also comes in both
untyped and typed variants.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Showing
ccan/order/LICENSE
0 → 120000
ccan/order/_info
0 → 100644
ccan/order/order.h
0 → 100644
ccan/order/test/compile_ok.c
0 → 100644
ccan/order/test/fancy_cmp.h
0 → 100644
Please register or sign in to comment