今天找了半天使用find函数的方法,发现都不怎么使用,于是自己定义了一个函数
vector<CPoint>::const_iterator find_val(vector<CPoint>::const_iterator beg,//vector首地址
vector<CPoint>::const_iterator end,//vector末地址
CPoint Point)//要查找的point变量
{
vector<CPoint>::const_iterator iter=end;
for(;beg!=end;beg++)
{
if((*beg).x==Point.x && (*beg).y==Point.y)
{
iter=beg;
return iter;
}
}
return iter;
}
如果找到该数据 返回该数据的地址,并可以获得与其相邻的数据地址。