开发者

efficient way of searching a character in a set of character C language

I have a set of characters, minimum hundreds of characters. How could i get the position 开发者_如何学编程of a particular character in that list efficiently.


If you set of characters is sorted, you can use bsearch().

If not, you're pretty much out of luck - you'll have to use a simple scan, like strchr().


convert the set into a ordered list and use binary search.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜