Skip to content

Latest commit

 

History

History
10 lines (10 loc) · 413 Bytes

9.22.md

File metadata and controls

10 lines (10 loc) · 413 Bytes
vector<int>::iterator iter = iv.begin(),
                      mid = iv.begin() + iv.size()/2;
while (iter != mid) {
  if (*iter == some_val) {
    iv.insert(iter, 2 * some_val);  // Error, we should update the iter
    iter = iv.insert(iter, 2 * some_val);
    ++iter;  // Increament to point to the original value
  }
  ++iter;  // Increment to point to the next value
}