嗨人们一个快速的问题:
我已将向量设置为特定大小,我想要做的是在该向量达到最大空间后清空该向量。
我有这个代码:
vector<Point> Rightarm(20);
vector<Point> Leftarm(20);
vector<Point>::const_iterator RightIter;
vector<Point>::const_iterator LeftIter;
Rightarm.push_back(center);
Leftarm.push_back(center1);
for(RightIter = Rightarm.begin(); RightIter != Rightarm.end(); ++RightIter)
{
circle(drawing, *RightIter, 3, Scalar(0,255,0), CV_FILLED);
}
if(RightIter == Rightarm.end())
{
Rightarm.clear();
}
for(LeftIter = Leftarm.begin(); LeftIter != Leftarm.end(); ++LeftIter)
{
circle(drawing, *LeftIter, 3, Scalar(0,255,0), CV_FILLED);
}
if(LeftIter == Leftarm.end())
{
Leftarm.clear();
}
我对这段代码的问题是每次都清除向量......我希望它只有在达到 20 的大小限制后才被清空......
谁能发现这哪里出了问题......?