• David Gibson's avatar
    order: Module for comparison callbacks · c2a3098b
    David Gibson authored
    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: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    c2a3098b
LICENSE 18 Bytes