vector help

closed account (jGAShbRD)
i have a vector<Typename> which is a container with unknown amount of elements. i have a int first = 0 which corresponds to first element. and last which is last element i want to add an item into vector. but with a couple of restrictions.
1. suppose my vector is a b c d e with first = 2 and last = 4. then the element to be added will be at 0 to replace the a and have last = 0.
2. suppose my vector a b c d e with first = 3 and last = 0. then i want to the element to replace b and have last = 1.
3. if i have a vector a b c d e with first = 4 and last = 3.then i want to add a new element how?
in my constructor i have
int sizeofmyvector = 0;
vector1.reserve(size);
int amounnt_of_elements = 0;
int first = 0;
and i want to implement void add(const typename & element); //Adds a new element to the end
Is this a continuation of: http://www.cplusplus.com/forum/general/271004/

Sounds like you have a "circular buffer". I think you should post the definition of the class that has a vector as the buffer.
Topic archived. No new replies allowed.