![]() ![]() I tried to have a look at the boost::split code:īut I fear I'm not familiar enough with boost / c to really grasp why it is (that much) faster. Would you please be so kind as to explain how ropes could help make this faster?įor the record, I just learnt about them by you mentioning them, but wikipedia compares them to array-based strings: (data_structure)#Comparison_with_monolithic_arraysįrom other articles, it seems like ropes only become beneficial when used on large strings, so it seems (like usual) there is no "one fastest way", it depends on the size of string you're intending to split. I really should make some time to read through all of the articles in there. Thanks very much for your link to that faq-entry Duoas, very informative and well written as always. Perhaps one of the experts around here could give a better, perhaps more low level approach that would be faster. I already tried different approaches - including strtok and stringstream - but it's always terrible slow compared to Java String.split(). Don't forget to turn on your compiler's optimizations too. Hey, what is the fastest way to split a string with a delimiter into a vector/array with C/C and STL The only limitation is that I don't want to use boost. Note that I haven't benchmarked it, I thought I'd leave comparison up to you since it would make more sense to compare to your existing results. Std::copy(container.cbegin(), container.cend(), ostr_it) Std::ostream_iterator ostr_it(std::cout, "\n") ![]() ![]() While (end container = string_split(s, ',') Std::vector string_split(std::string s, const char delimiter) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |