fast search

Does anyone know a very fast searching function?I have to find some characters in long strings(10+ strings ,wach with 500 chars).I use now str.fin(str2); but its not fast enough...
I doubt that you will find a better generic search function for strings than provided by your stl implementation. If you *really* think you can, I suggest that you replace the complete stl with a better version.
BTW, with 10*500 chars there will be no measurable time needed to find a substring, even if you construct the worst-case-scenario for your implementation. I therefore suggest the usage of a profiler to see what really is the reason why your program is not fast enough.
Let's see some code! Optimization is always fun!
Thanks.I'll try some STL things.The find algorithm complexity there is only log N..
I would guess that you have confused some find()-functions here. The standard does not specify a complexity for finding a substring, but as can be shown easily, Omega(n*m) for a string of lenght n and a substring of length m is the worst case lower bound (which can easily achieved as upper bound as well), so my guess is that any serious STL implementation has this complexity and thus is - optimal.
Last edited on
Topic archived. No new replies allowed.