tikimyster

insertion attempt

Oct 3rd, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. //This if statement is just for a certain sorting method passed from main. If its values then I sort by the string of the vector.  
  2. if(value_key == "values")
  3.     {
  4. //This vector is as such vector<pair <string,int > > myVector
  5. //Also defined in a class previously
  6.  
  7. //what i thought was happening here was i set VectIt to the begining of my filled vector then I advanced that iterator by 1 so its now in the next vector slot. And I wanted it to do this loop till it reached the end of the vector increasing VecIt every time by one.
  8.         for((VecIt = myVector.begin())+1;VecIt!=myVector.end();VecIt++)  
  9.         {
  10.  
  11. //Here on out I tried to throw something together from the book. Accept my book used an array. It mentioned something about having a KEY value. Which I don't know how to relate to my vector. Also it used i and j a lot. I'm just confused.
  12.  
  13.             tmpIt = VecIt - 1; //tmpIt is another iterator defined in a class earlier on.
  14.             while(tmpIt->first > "0" && tmpIt->first > VecIt->first)
  15.             {
  16.                 VecIt = tmpIt;
  17.                 tmpIt = tmpIt-1;
  18.             }
  19.             tmpIt+1 = VecIt;
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment