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.
精彩评论