Hello all,
What is the simplest code to use to "flip" an std::vector? The last element is the first and so on...
Thanks!
Printable View
Hello all,
What is the simplest code to use to "flip" an std::vector? The last element is the first and so on...
Thanks!
std::reverse
std::reverse if of course right, but there is hardly ever a need for reversing a vector, because you can iterate a vector back to front as well as front to back. So why waste CPU time on reversing it?Quote:
Originally Posted by lab1
Does std::reverse work on burgers too? I need to know for next time I'm out of computing work.
Maybe you're passing it to a function (that you can't change) that requires it in the opposite order. I had a situation where data was in one order in the application, but an error correction library required it in reverse order. It may be that the data decodes in one order but the reverse makes more logical sense subjectively, and you don't want to use reverse iterators all over the place.
It would probably have to be std::flipQuote:
Originally Posted by NMTop40