unsigned int j = 0;
openListIterator = openListVector.begin ();
while (exitPointDetailsVector[lowestWeightedPointInOpenList.pointId].branchesVector[m].connectedExitPoint >= openListVector[j].pointId)
&& (openListIterator <= openListVector.end()))
{
// Move the iterator.
openListIterator++;
// Move the index.
j++;
}
// Insert in the vector in the required position.
listStruct objOpenListStruct;
objOpenListStruct.pointId = exitPointDetailsVector[lowestWeightedPointInOpenList.pointId].branchesVector[m].connectedExitPoint;
objOpenListStruct.weight = exitPointDetailsVector[lowestWeightedPointInOpenList.pointId].weight + exitPointDetailsVector[lowestWeightedPointInOpenList.pointId].branchesVector[m].distance;
objOpenListStruct.parentPointId = exitPointDetailsVector[lowestWeightedPointInOpenList.pointId].exitPoint;
***********openListVector.insert (openListIterator, objOpenListStruct);
This code is under a for loop.
But I have put the proper the iterator initialization, still I am getting a segmentation fault, on the starred line.
Any hints?
In the statement
openListIterator <= openListVector.end(), if you reachopenListIterator == openListVector.end(), then you’re going to have a segfault, because when the code reachesopenListIterator++, your iterator becomes “out of bound”Try
openListIterator != openListVector.end()