CFComparatorFunction |
||||
Header: | CFBase.h | Carbon status: | Supported | |
The prototype for a user-defined function that compares two values. You provide a pointer to this function in certain Core Foundation sorting functions.
typedef CFComparisonResult(* CFComparatorFunction) ( const void *val1, const void *val2, void *context );
You would declare your function like this if you were to name it MyCallback:
CFComparisonResult MyCallback ( const void *val1, const void *val2, void *context );
Pass a pointer to the first value to be compared.
Pass a pointer to the second value to be compared.
An untyped pointer to the context of the evaluation. This is often used for user-defined data in the comparison.
An integer value of type CFComparisonResult that indicates whether the first value is equal to, less than, or greater than the second value.
If you need to sort the elements in a collection using special criteria, you can implement a comparator function with the signature defined by the CFComparatorFunction prototype. You pass a pointer to this function in one of the "sort" functions, such as CFArray's CFArraySortValues.
You can also pass pointers to standard Core Foundation comparator functions such as CFStringCompare and CFDateCompare.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)