does anyone know the current running time for this c-string function: memchr()? is it constant/O(1), or O(size of string) ?
Printable View
does anyone know the current running time for this c-string function: memchr()? is it constant/O(1), or O(size of string) ?
I don't really get what do you mean by "current running time", but the function
returns a pointer to the first occurence of ch in the first count characters of the given buffer.Code:void* memchr( const void *buf, int ch, size_t count );
If none found, it returns a NULL pointer.
Hope I answered your question.
Hint: www.cppreference.com/stdstring_details.html#memchr
It runs in linear time (O(n)) if that's what you want.
I'm not sure how you expect a search function on unsorted linear memory to be any faster.
not expecting but hoping :) thanksQuote:
Originally posted by CornedBee
It runs in linear time (O(n)) if that's what you want.
I'm not sure how you expect a search function on unsorted linear memory to be any faster.
Hoping against all logic? :)
>> Hoping against all logic?
that is what miracles are, aren't they? LOL....I thought that is was linear...but couldn't find any documentation to prove it....