Tag: STL
All the articles with the tag "STL".
-
How to Get the Size of a Vector in C++
Use v.size() to get the number of elements in a C++ vector. Covers size vs capacity, the unsigned size_t trap, empty(), and 2D vectors.
-
How to Remove a Character from a String in C++
Remove characters from a C++ string with erase, the erase-remove idiom, and remove_if. Delete by index, by value, all spaces, or every character matching a rule.
-
How to Sort a Map by Value in C++
A std::map always sorts by key, never by value. Here is the standard way to sort map entries by value in C++ using a vector of pairs, plus ties and top-N.
-
How to Use a Vector of Pairs in C++
Create, fill, sort and iterate a std::vector of std::pair in C++. Sort by first or second element, use structured bindings, and know when to use a map instead.