【发布时间】:2022-01-19 01:34:19
【问题描述】:
我有一个充满单词的向量,我试图在指定的开头和结尾擦除该向量的一部分。例如:
#include <string>
#include <vector>
int main() {
std::vector<std::string> words = { "The", "Quick", "Brown", "Fox", "Jumps", "Over", "The", "Lazy", "Dog" };
remove_chunk(words, 1, 2);
}
这里,remove_chunk(words, 1, 2); 将删除索引 1 到 2 处的项目,留下向量:
{ "The", "Fox", "Jumps", "Over", "The", "Lazy", "Dog" }
我将如何高效地编写remove_chunk?是否有 stl 功能或快速单线?
【问题讨论】: