Calico
linear_ordered_search.h File Reference

Linear ordered search. More...

Functions

static int cal_linear_ordered_search (const void *key, const void *ptr, size_t count, size_t size, int(*cmp)(void *, const void *, const void *), void *cmp_ctx, size_t *pos_out)
 Perform a linear search on a pre-sorted array pointed by ptr. More...
 

Detailed Description

Linear ordered search.

Function Documentation

static int cal_linear_ordered_search ( const void *  key,
const void *  ptr,
size_t  count,
size_t  size,
int(*)(void *, const void *, const void *)  cmp,
void *  cmp_ctx,
size_t *  pos_out 
)
inlinestatic

Perform a linear search on a pre-sorted array pointed by ptr.

If the search was successful, 1 is returned and *pos_out is set to the index of the element that compares equal to key. Otherwise, 0 is returned and *pos_out is set to the index of the smallest element greater than key. pos_out is optional and can be null.