C++ STL - Cheat SheetPrevious Quiz Next This C++ STL cheatsheet covers a wide range of topics from basic STL like vectors, hashmaps, sets, etc., to advanced concepts like functors, iterators, and so on. It is designed for programmers who want to quickly read through key concepts along ...
awesome-cpp Latest commit uhub update Feb 7, 2025 c906828·Feb 7, 2025 History History A curated list of awesome C++ frameworks, libraries and software.
stdunordered_mapumcout<<"Unordered map contains following elements before erase operation"<<endl;for(autoit=um.begin();it!=um.end();++it)cout<<it->first<<" = "<<it->second<<endl;um.erase(um.begin());cout<<endl;cout<<"Unordered map contains following elements after erase operation"<...
Time complexity Linear i.e. O(n) Example The following example shows the usage of std::stack::stack() constructor. Open Compiler #include <iostream> #include <stack> #include <vector> using namespace std; int main(void) { stack<int> s1; vector<int> v = {1, 2, 3, 4, 5}; stac...
The C++ STL Library C++ Library - <array> C++ Library - <bitset> C++ Library - <deque> C++ Library - <forward_list> C++ Library - <list> C++ Library - <map> C++ Library - <multimap> C++ Library - <queue> C++ Library - <priority_queue> C++ Library - <set> C++ Library - <stack...
Time complexity Logarithmic i.e. O(log n) Example The following example shows the usage of std::multimap::insert() function. Open Compiler #include <iostream> #include <map> using namespace std; int main(void) { /* Multimap with duplicates */ multimap<char, int> m1 { {'a', 1}, ...
Time complexity Linear in size of other; i.e. O(n) Example The following example shows the usage of std::set::set() copy constructor. Open Compiler #include <iostream> #include <set> using namespace std; int main(void) { //Default Constructor std::set<int> t_set; t_set.insert(5...
Time complexity Logarithmic i.e. O(log n) Example The following example shows the usage of std::multimap::insert() function. Open Compiler #include <iostream> #include <map> using namespace std; int main(void) { /* Multimap with duplicates */ multimap<char, int> m { {'a', 1}, {...
The C++ STL Library C++ Library - <array> C++ Library - <bitset> C++ Library - <deque> C++ Library - <forward_list> C++ Library - <list> C++ Library - <map> C++ Library - <multimap> C++ Library - <queue> C++ Library - <priority_queue> C++ Library - <set> C++ Library - <stack...
Time complexity The time complexity of this function is Constant i.e. O(1) Example In the following example, we are going to consider the basic usage of the begin() function. Open Compiler #include <iostream> #include <initializer_list> void a(std::initializer_list < int > x) { auto...