// 测试两种vector参数的区别
test_vector_func(std::vector<std::string> v1, std::vector<std::string>& v2)
{
CCLOG("[1] 0x%x 0x%x", &v1, &v2);
v1.clear();
v2.clear();
}
std::vector<std::string> v1 = {"1", "2", "3"};
std::vector<std::string> v2 = { "1", "2", "3" };
CCLOG("[0] 0x%x 0x%x", &v1, &v2);
test_vector_func(v1, v2);
// 测试两个vector之间的批量复制
// 把v2全部复制到v1当中
std::vector<std::string> v1;
std::vector<std::string> v2 = { "1", "2", "3" };
v1.insert(v1.begin(), v2.begin(), v2.end());
// 遍历删除vector
// 如果v1中包含v2中的点,则将v1中的该点删除
void removePos(std::vector<Data>& v1, Vector<Data>& v2)
{
for (auto it = v1.begin(); it != v1.end(); )
{
Point pos = (*it)->pos;
bool isFind = false;
for (auto it2 = v2.begin(); it2 != v2.end(); ++it2)
{
Point pos2 = *it2->pos;
if (pos == pos2)
{
isFind = true;
break;
}
}
if (isFind)
{
it = v1.erase(it);
}
else
++it;
}
}