i have a vector<T> storage that is a container, lets say inside i got 1,2,3,4,5 with head at 1 and end at 5. i want to remove 1 but i dont want to use .erase instead i want to remove 1 and have head be 2. also how do i add to end of vector assuming that once again i have " " 2, 3,4,5 and 2 is head and 5 is end i want to have 6 added inplace of "" and have end point to 6 how do i do this? can someone explain.
what if like our vector has 5 elements but we want to add a 6th element, and the vector container would double to hold 10 elements. from what i learn it would have 1,2,3,4,5,6, and the rest of the vecotr would contain smething to hold how would we do it that way?
i know what you men but i meant like, im creating a class that does these for me
so like wen u say add to the end i also thought of pushback as best way but then i have to consider the fact that lets say we have a given vector with first element as 1 then 2 3 4 5 and last element is 5. lets say previously i had a function that removes the first element of the vector so 1 is remove as well as set the first element to 2. so this vector would be _ 2 3 4 5 the _ is the previous first element before removed. now i want to add a elelement in place of the _ lets say 6. if i do pushback it would be _ 2 3 4 5 6 _ _ _ _ _ . where _ are shows the size of the vector. but i want it to be 6 2 3 4 5 . its like a cirualr queue but in vector container.
Also, the vector's size is dynamic, it's as big as it needs to be to hold the elements. Behind the scenes, the capacity of the vector may be larger than you need, but using .size() will get you the amount of elements you can access.