   Vector manipulation
  Hi guys i need some help.I need to create a vector that does some special stuff, and i'm looking for the simplest solution.I need a way of adding stuff to the end of the vector (actually i know how to do that its pushback)I need a way of deleting the first row of the vector and moving the second row into the first, if you get what i mean?e.g. 1    something12    something23    something34    something4something1 gets deletedand the vector looks like this:1    something22    something33    something44    //space to add somethingAny comments welcomeJamesCobras   
  Just for future reference, calling them "rows" is a little misleading (it makes it sound like you're talking about a 2D table).  "Elements" is a little clearer.  Anyway, I think the best solution depends on what you're trying to do.  Can you give us further information on what this special functionality is supposed to help you accomplish?   ;  I haven't worked too much with vectors, but I am fairly sure they work like arrays and this is how I could do it with an array.int num = 5;int something[num];//Number is the number of elements.for ( i = 0; i <= num-1; i++){something = something[i+1]}something[4] = newsomething;   ;  Right,This is used for allowing an object to follow another.The position of the object is recorded at intervals and saved (in a vector)then normalisation * by movement amount and then other stuff to determine the step of the object and in what position.If within a tolerance of a position (one of the recorded positions) stop trying to move towards it and set up the movement for the next one. Therefore i need to delete the first entry in the vector and shift all elements up, so i can grab the first one and this loops until within x units of object.I really want to do it exactly that way so i just need the function to delete and move all elements up in the vector.JamesCobras   ;  Or you could work in reverse.  For example, store the elements in the array backwards so that the one you want to access is easily accessed through the vector's back() method.  Then you just pop_back() to remove the back element and then back() will grab the next element you want.You can either insert your elements into the vector in backwards order, or you can insert them into the vector normally and call std::reverse() to reverse the vector when you want to start working with it.@DeFessler: you should be using < rather than <=, just FYI.  But you can't assign arrays like that so it would look a little more like this:std::vector<int> v;populateVector(v); // fill the vector with some values// now move all the elements up 1for (std::size_t i = 0; i < v.size() - 1; i++){    v = v;<br>}<br><br>// now pop the back element, otherwise the last element would be duplicated<br>v.pop_back();</pre>;  I would use a linked list in this case (such as std::list), which allows easy access from both ends. Just add to the end and remove from the beginning. You don't need random access and don't do iteration through the container, so it will behave well performance wise too.   ;  Can i have example code?JamesCobras   ;Quote:Original post by JamesCobrasCan i have example code?JamesCobrasSure:#include <list>int main(){  std::list<int> myList;  myList.push_back(5);  myList.push_back(3);  myList.push_back(2);  // here myList contains {5,3,2}  int front = myList.front();  // here front contains 5  myList.pop_front();  // here myList contains {3,2}  return 0;}Easy as pie.