I have this new class Seq that inherits vector and has some additional features. I can use all methods of vector with Seq. Having this data structure:
Seq< vector<int> > sweepEvents;
I want to have a function that takes an element vector edge search for it in sweepEvents and returns the iterator to the position of the found element in sweepEvents (iff edge is found) and the iterator to the last elements of the vector (iff edge is not found)
Then I want to work with this iterator, in that I want to compare the elements from the prev and the next position of iterator.
I have the following function for founding and returning the iterator:
Seq< vector<int> >::iterator QSweep::insertSweepEvents(edge_t edge,int currentDim){
int changePosition;
int found=0;
for (int i=0;i<currentDim;i++){
if (edge[0]==sweepEvents[i][1]){
changePosition=i;
found=1;
return sweepEvents.begin()+changePosition;
}
}
if (found==1){
sweepEvents.rep().insert(sweepEvents.begin()+changePosition,edge);
sweepEvents.rep().erase(sweepEvents.begin()+changePosition+1);
}
else{
sweepEvents.rep().insert(sweepEvents.end(),edge);
}
return sweepEvents.end()-1;
}
and then I call this iterator in the main function, actually I tried but it does not compile and I do not know what syntax to use other than this
int main(){
Seq< vector<int> > sweepEvents;
vector<int> edge;
//.....initialize sweepEvents and edge
//declare iterator but not working
Seq< vector<int> >::iterator comparePosition;
//not working neither
comparePosition=insertSweepEvents(edge,sweepEvents.size());
}
Any idea on how I should correctly call the iterator? I see it does not work as an integer index from an array?
thank you in advance for your suggestions, madalina