Is it possible in C++11 "cut and paste" the last k elements of an std::vector A to a new std:::vector B in constant time?
One way would be to use B.insert(A.end() - k, A.end()) and then use erase on A but these are both O(k) time operations.
B.insert(A.end() - k, A.end())
Mau
Aucun commentaire:
Enregistrer un commentaire