I am writing a couple string sort algorithm with c++ and I wonder if I can make this swap operation faster.
void swap(string *items,int a, int b ){
string temp;
temp = items[a];
items[a] = items[b];
items[b] = temp;
}
I’ll be appreciate if you can help…
String class has its own swap function.
It’s the fastest way to do this because it accesses the string internals and avoids all copying.
See here.