Skip to content

Instantly share code, notes, and snippets.

@berkeley-db
Created January 23, 2011 19:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save berkeley-db/792367 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment