value propagation in a std::vector
c++
Solution
Changing the container (e.g. std::deque) is the only option if O(N) is an issue.
However, do make sure that O(N) really is an issue!
Problem
If I have a `std::vector` initialized like this: ``` 0 1 2 3 4 5 ``` how can I best propagate the 4 to the first place? I.e. I want the `std::vector` in this state: ``` 4 0 1 2 3 5 ``` Removing the 4 and reinserting it could be expensive, as insertions at the front are `O(N)`, I believe. I was thinking about swapping values in successive places (like in bubble sort), but that would be also `O(N)`. Is using another container, like `std::list` the only way? EDIT: After seeing some confusion, let me clarify, that my objective is to prepend a value at a known arbitrary location in the `std::vector` in front of a value at another known location in the `std::vector`.