utils/algorithms.h file

Various algorithms.

Contents

Defines

#define algorithms_binary_search_nearby(arr, sval, rprev, inc_eq, count, type, cmp, amp, ret, null)
Conducts binary search on the object's member array to find the previous or next member closest to the given one.

Define documentation

#define algorithms_binary_search_nearby(arr, sval, rprev, inc_eq, count, type, cmp, amp, ret, null)

Conducts binary search on the object's member array to find the previous or next member closest to the given one.

Parameters
arr The array.
sval Value to search with.
rprev 1 to return previous element, 0 for next.
inc_eq Include equal points (if an exact match is found, return it).
count Element count.
type Data type of each element. If the data type is MyStruct then "MyStruct *" should be passed with the "&" character passed to amp.
cmp Comparator function for two elements.
amp The & symbol, if the array does not contain primitives or pointers. In this case, type must also contain an asterisk.
ret Variable to store the return value in.
null Value to set to ret if nothing found.