public
Created

  • Download Gist
stl-ex-1d.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
for(dbl_vec_t::iterator itr = v1.begin(); itr != v1.end(); ++itr)
*itr *= 2;
 
for (int i = 0; i < v1.size(); i++)
v1[i] += 3;
 
v1.swap(v2); // Swap the vector's contents.
v2 = v1; // Assign one vector to another.
assert(v1 == v2);
std::reverse(v1.begin(), v1.end());
// More standard features follow ...
 
for(dbl_vec_t::reverse_iterator ritr = v1.begin(); ritr != v1.rend(); ++ritr)
*ritr /= 2;
 
v1.pop_back();
v1.insert(v1.begin(), 34);
assert(v1.front() == 34);
v2.assign(v1.begin(), v1.end());
 
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.