I have a customized array implementation for a geometry (vertex) . Each element of the array is represented by the vertex which has a Point . Now I want to check the distance between each point for the vertex in the array . So essentially for every vertex in the array of size n I will loop till n and calculate the distance of vertex point with all n vertex points in the array . So a pseudo code will look like this
func MyFunc( Array iVrtxList , vrtx inpVertex )
{
point refPt = inpVertex->getPoint();
for ( i=0 ; i < iVrtxList.size(); i++)
{
if( distanceBetween(iVertexList(i).point ,rePt ) == 0 )
return
}
iVrtxList.add(inpVertex);
}
}
So I want to avoid N X N looping . I thought of sorting the container and then check only the subsequent element for the distance . However I seem to miss some elements