std::bsearch
From Cppreference
Defined in header <cstdlib>
|
||
void *bsearch( const void *key, const void *ptr, size_t count, size_t size,
int (*comp)(const void *, const void *) ); |
||
Finds an element equal to element pointed to by key in an array pointed to by ptr. The array contains count elements of size size. Function pointed to by comp is used for object comparison.
Contents |
[edit] Parameters
key | - | pointer to the element to search for | |||||||||
ptr | - | pointer to the array to examine | |||||||||
count | - | number of element in the array | |||||||||
size | - | size of each element in the array in bytes | |||||||||
comp | - | comparison function which returns a negative integer value if the first argument is less than the second, a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second.
The function must not modify the objects passed to it. |
[edit] Return value
pointer to the found element or NULL otherwise.
[edit] Example
This section is incomplete |
[edit] See also
|
sorts a range of elements with unspecified type (function) |
|
|
returns range of elements matching a specific key (function template) |