{"id":28291,"date":"2021-03-23T18:38:34","date_gmt":"2021-03-23T13:08:34","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/"},"modified":"2024-09-03T11:08:27","modified_gmt":"2024-09-03T05:38:27","slug":"standard-template-library-in-c","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/","title":{"rendered":"Standard Template Library in C++"},"content":{"rendered":"\n<p>Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.<\/p>\n\n\n\n<p>As a programmer one has to make sure to store data in such a way, that the retrieval and manipulations become easy to resolve this is called a Standard Template Library (STL). Many innovators who intend to bring a massive change in various tech fields are working on designing new algorithms and implementations respectively, and storing data becomes a tough task, eventually, that makes room for great importance about STL in C++ that resolves their queries to large extends.&nbsp;<\/p>\n\n\n<figure class=\"wp-block-image size-large td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23.png zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23.png\"><img decoding=\"async\" width=\"1024\" height=\"332\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-1024x332.png\" alt=\"\" class=\"wp-image-28292\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-1024x332.png 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-300x97.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-768x249.png 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-696x225.png 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-1068x346.png 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23-150x49.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23.png 1124w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Containers<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>This helps the programmer to store the data in the listed below containers for further operations on the data.<\/li><li>It\u2019s like people standing in the row; with the power in the hands of the executor to manipulate the row in his\/her choice and can add more people in the row in any fashion.<\/li><\/ul>\n\n\n\n<p>Here is the list of some commonly used containers to hold the data -&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Container<\/strong><\/td><td><strong>Description<\/strong><\/td><td><strong>Header file<\/strong><\/td><\/tr><tr><td>Vector<\/td><td>A dynamic array that permits the insertion and deletion of data from the end of the vector.<\/td><td>&lt;vector&gt;<\/td><\/tr><tr><td>Lists<\/td><td>Allows non-contiguous memory allocation just as in linked lists, insertion, and deletion can be done from anywhere in the list.<\/td><td>&lt;list&gt;<\/td><\/tr><tr><td>Queue<\/td><td>Follow FIFO (first-in-first-out) what comes in first will come out first.<\/td><td>&lt;queue&gt;<\/td><\/tr><tr><td>Stack<\/td><td>Follows LIFO (last-in-first-out)&nbsp;<\/td><td>&lt;stack&gt;<\/td><\/tr><tr><td>Set<\/td><td><a href=\"https:\/\/www.mygreatlearning.com\/blog\/set-in-cpp\/\">Set in c++<\/a> allows no duplicity and input data is stored in a particular order (increasing). Unique values are stored.<\/td><td>&lt;set&gt;<\/td><\/tr><tr><td>Map<\/td><td>No duplicity is allowed and data is not stored in a particular order. It always stores data in the form of a key-&gt;value pair.<\/td><td>&lt;map&gt;<\/td><\/tr><tr><td>Multiset<\/td><td>It stores a non-unique set. Duplicity is allowed.<\/td><td>&lt;set&gt;<\/td><\/tr><tr><td>Multimap<\/td><td>Here multiple values are associated with the same key.<\/td><td>&lt;map&gt;<\/td><\/tr><tr><td>Priority Queue<\/td><td>Here the elements are taken out of the queue based on priority. This is mainly used for implementing heaps.<\/td><td>&lt;queue&gt;<\/td><\/tr><tr><td>Deque<\/td><td>Also known as a doubly ended queue where insertion and deletion can be done on both the ends and its size is dynamic which can be increased or decreased from both ends.<\/td><td>&lt;queue&gt;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<figure class=\"wp-block-image size-large td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a.png zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a.png\"><img decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-1024x539.png\" alt=\"\" class=\"wp-image-28294\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-1024x539.png 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-300x158.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-768x404.png 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-696x366.png 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-1068x562.png 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-798x420.png 798w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a-150x79.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23a.png 1130w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Sequential Container Code:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n#include&lt;vector&gt;\n#include&lt;iostream&gt;\n#include&lt;list&gt;\n#include&lt;queue&gt;\n\nusing namespace std;\nint main()\n{\n\t\/\/vector\n\tvector&lt;int&gt;v;\n\tfor(int i=1;i&lt;=10;i++)\n\t{\n\t\tv.push_back(i); \/\/push_back() function inserts element into the vector\n\t}\n\tcout&lt;&lt;\"Elements in the vector : \";\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n\tcout&lt;&lt;\"\\nSize of the vector v is : \"&lt;&lt;v.size()&lt;&lt;endl;\/\/v.size() compute the size of the vector\n\tcout&lt;&lt;endl&lt;&lt;endl;\n\t\n\t\/\/list\n\tlist&lt;int&gt;l1,l2;\n\tfor(int i=1;i&lt;11;i++)\n\t{\n\t\tl1.push_back(i); \/\/ push_back() inserts the element from the back of the list\n\t\tl2.push_front(i); \/\/ push_front() inserts the element from the front of the list\n\t}\n\tcout&lt;&lt;\"Elements in list1 : \";\n\tfor(auto i=l1.begin();i!=l1.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \";\n\tcout&lt;&lt;\"\\nElements in list2 : \";\n\tfor(auto i=l2.begin();i!=l2.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \";\n\tcout&lt;&lt;\"\\nSize of list1 : \"&lt;&lt;l1.size()&lt;&lt;endl; \/\/ l1.size() tells how many elements are there in list\n\tcout&lt;&lt;\"size of list2 : \"&lt;&lt;l2.size()&lt;&lt;endl;\n\t\/\/front() returns the element present at the front of the list and back() returns the element present at the end of the list\n\tcout&lt;&lt;\"Element at the front of list1 and list2 respectively : \"&lt;&lt;l1.front()&lt;&lt;\"   \"&lt;&lt;l2.front()&lt;&lt;endl;\n\tcout&lt;&lt;\"Element at the back of list1 and list2 respectively : \"&lt;&lt;l1.back()&lt;&lt;\"  \"&lt;&lt;l2.back();\n\t\/\/ pop_fornt() removes element front the front of the list and pop_back() removes element from the back of the list\n\tl1.pop_front();\n\tl2.pop_back();\n\tcout&lt;&lt;endl;\n\tcout&lt;&lt;\"Lists1 after pop_front : \";\n\tfor(auto i=l1.begin();i!=l1.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \";\n\tcout&lt;&lt;endl;\n\tcout&lt;&lt;\"List2 after pop_back :\";\n\tfor(auto i=l2.begin();i!=l2.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \";\n\tcout&lt;&lt;endl&lt;&lt;endl;\n\t\n\t\/\/deque\n\tdeque&lt;int&gt;dq; \n    dq.push_back(5); \/\/push_back() inserts element from the back,  and push_front inserts element from the front of the dque\n    dq.push_front(2); \n    dq.push_back(10); \n    dq.push_front(9); \n    cout &lt;&lt; \"The deque elements is : \"; \n    for(auto i=dq.begin();i!=dq.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \"; \n  \n    cout &lt;&lt; \"\\ndq.size() : \" &lt;&lt; dq.size(); \n    cout &lt;&lt; \"\\ndq.max_size() : \" &lt;&lt; dq.max_size(); \n  \n    cout &lt;&lt; \"\\ndq.at(2) : \" &lt;&lt; dq.at(3); \/\/returns the element at the specific position\n    cout &lt;&lt; \"\\ndq.front() : \" &lt;&lt; dq.front(); \/\/returns the front element\n    cout &lt;&lt; \"\\ndq.back() : \" &lt;&lt; dq.back(); \/\/ returns the element present at the back\n  \n    cout &lt;&lt; \"\\ndq.pop_front() : \"; \/\/pops the element from the front\n    dq.pop_front(); \n    for(auto i=dq.begin();i!=dq.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \"; \n  \n    cout &lt;&lt; \"\\ndq.pop_back() : \"; \n    dq.pop_back(); \/\/ pops element from the back of the dque\n    for(auto i=dq.begin();i!=dq.end();i++)\n\tcout&lt;&lt;*i&lt;&lt;\" \"; \n}\n\n\n\n<\/code><\/pre>\n\n\n\n<p>Associative Container Code:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\n#include&lt;map&gt;\n#include&lt;set&gt;\n#include&lt;iterator&gt;\n\nusing namespace std;\nint main()\n{\n\t\/\/ empty map container \n    map&lt;int, int&gt; m; \n  \n    \/\/ insert elements in random order \n    m.insert(pair&lt;int, int&gt;(1, 4)); \n    m.insert(pair&lt;int, int&gt;(2, 3)); \n    m.insert(pair&lt;int, int&gt;(3, 6)); \n    m.insert(pair&lt;int, int&gt;(4, 10)); \n    m.insert(pair&lt;int, int&gt;(5, 80)); \n    m.insert(pair&lt;int, int&gt;(6, 1)); \n    m.insert(pair&lt;int, int&gt;(7, 5)); \n  \n    \/\/ printing map m \n    map&lt;int, int&gt;::iterator itr; \n    cout &lt;&lt; \"\\nThe map m is : \\n\"; \n    cout &lt;&lt; \"\\tKEY\\tELEMENT\\n\"; \n    for (itr = m.begin(); itr != m.end(); ++itr) { \n        cout &lt;&lt; '\\t' &lt;&lt; itr-&gt;first \n             &lt;&lt; '\\t' &lt;&lt; itr-&gt;second &lt;&lt; '\\n'; \n    } \n    cout &lt;&lt; endl; \n  \n    \/\/ assigning the elements from m to n \n    map&lt;int, int&gt; n(m.begin(), m.end()); \n  \n    \/\/ print all elements of the map n \n    cout &lt;&lt; \"\\nThe map n after\"\n         &lt;&lt; \" assign from m are : \\n\"; \n    cout &lt;&lt; \"\\tKEY\\tELEMENT\\n\"; \n    for (itr = n.begin(); itr != n.end(); ++itr) { \n        cout &lt;&lt; '\\t' &lt;&lt; itr-&gt;first \n             &lt;&lt; '\\t' &lt;&lt; itr-&gt;second &lt;&lt; '\\n'; \n    } \n    cout &lt;&lt; endl; \n  \n    \/\/ remove all elements up to \n    \/\/ element with key=3 in n \n    cout &lt;&lt; \"\\nn after removal of\"\n            \" elements less than key=3 : \\n\"; \n    cout &lt;&lt; \"\\tKEY\\tELEMENT\\n\"; \n    n.erase(n.begin(), n.find(3)); \n    for (itr = n.begin(); itr != n.end(); ++itr) { \n        cout &lt;&lt; '\\t' &lt;&lt; itr-&gt;first \n             &lt;&lt; '\\t' &lt;&lt; itr-&gt;second &lt;&lt; '\\n'; \n    } \n  \n    \/\/ remove all elements with key = 4 \n    int num; \n    num = n.erase(4); \n    cout &lt;&lt; \"\\nn.erase(4) : \"; \n    cout &lt;&lt; num &lt;&lt; \" removed \\n\"; \n    cout &lt;&lt; \"\\tKEY\\tELEMENT\\n\"; \n    for (itr = n.begin(); itr != n.end(); ++itr) { \n        cout &lt;&lt; '\\t' &lt;&lt; itr-&gt;first \n             &lt;&lt; '\\t' &lt;&lt; itr-&gt;second &lt;&lt; '\\n'; \n    } \n  \n    cout &lt;&lt; endl; \n  \n    \/\/ lower bound and upper bound for map m key = 5 \n    cout &lt;&lt; \"m.lower_bound(5) : \"\n         &lt;&lt; \"\\tKEY = \"; \n    cout &lt;&lt; m.lower_bound(5)-&gt;first &lt;&lt; '\\t'; \n    cout &lt;&lt; \"\\tELEMENT = \"\n         &lt;&lt; m.lower_bound(5)-&gt;second &lt;&lt; endl; \n    cout &lt;&lt; \"m.upper_bound(5) : \"\n         &lt;&lt; \"\\tKEY = \"; \n    cout &lt;&lt; m.upper_bound(5)-&gt;first &lt;&lt; '\\t'; \n    cout &lt;&lt; \"\\tELEMENT = \"\n         &lt;&lt; m.upper_bound(5)-&gt;second &lt;&lt; endl;\n\t\t \n\t\/\/SET\n\t\/\/ empty set container\n    set&lt;int,greater&lt;int&gt;&gt; s1;\n \n    \/\/ insert elements in random order\n    s1.insert(10);\n    s1.insert(8);\n    s1.insert(9);\n    s1.insert(2);\n    s1.insert(60);\n     \n    \/\/ only one 80 will be added to the set\n    s1.insert(80); \n    s1.insert(1);\n \n    \/\/ printing set s1\n    set&lt;int,greater&lt;int&gt;&gt;::iterator it; \/\/ iterator declaration\n    cout &lt;&lt; \"\\nThe set s1 is : \\n\";\n    for (it = s1.begin(); it != s1.end(); it++) \n    {\n        cout &lt;&lt; *it&lt;&lt;\" \";\n    }\n    cout &lt;&lt; endl;\n \n    \/\/ assigning the elements from s1 to s2\n    set&lt;int&gt; s2(s1.begin(), s1.end());\n \n    \/\/ print all elements of the set s2\n    cout &lt;&lt; \"\\nThe set s2 after assign from s1 is : \\n\";\n    for (it = s2.begin(); it != s2.end(); it++)\n    {\n        cout &lt;&lt; *it&lt;&lt;\" \";\n    }\n    cout &lt;&lt; endl;\n \n    \/\/ remove all elements up to 2 in s2\n    cout\n        &lt;&lt; \"\\ns2 after removal of elements less than 2 :\\n\";\n    s2.erase(s2.begin(), s2.find(2));\n    for (it = s2.begin(); it != s2.end(); it++) {\n        cout &lt;&lt;*it&lt;&lt;\" \";\n    }\n \n    \/\/ remove element with value 10 in s2\n    int num1;\n    num1 = s2.erase(10);\n    cout &lt;&lt; \"\\ns2.erase(10) : \";\n    cout &lt;&lt; num1 &lt;&lt; \" removed\\n\";\n    for (it = s2.begin(); it != s2.end(); it++) \n    {\n        cout &lt;&lt;*it&lt;&lt;\" \";\n    }\n \n    cout &lt;&lt; endl;\n \n    \/\/ lower bound and upper bound for set s1\n    cout &lt;&lt; \"s1.lower_bound(60) : \\n\"\n         &lt;&lt; *s1.lower_bound(60)\n         &lt;&lt; endl;\n    cout &lt;&lt; \"s1.upper_bound(60) : \\n\"\n         &lt;&lt; *s1.upper_bound(60)\n         &lt;&lt; endl;\n \n    \/\/ lower bound and upper bound for set s2\n    cout &lt;&lt; \"s2.lower_bound(9) :\\n\"\n         &lt;&lt; *s2.lower_bound(9)\n         &lt;&lt; endl;\n    cout &lt;&lt; \"s2.upper_bound(9) : \\n\"\n         &lt;&lt; *s2.upper_bound(9)\n         &lt;&lt; endl;\n \n    return 0;\t  \n  \n}\n<\/code><\/pre>\n\n\n\n<p>Derived Containers Code:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\n#include&lt;stack&gt;\n#include&lt;queue&gt;\n#include&lt;iterator&gt;\n\nusing namespace std;\nint main()\n{\n\t\/\/STACK\n\tstack &lt;int&gt; s,s1; \n    s.push(20); \n    s.push(4); \n    s.push(2); \n    s.push(7); \n    s.push(50);  \n  \n    cout &lt;&lt; \"\\ns.size() : \" &lt;&lt; s.size(); \n    cout &lt;&lt; \"\\ns.top() : \" &lt;&lt; s.top(); \n    s1=s;\n    \n    cout&lt;&lt;\"\\nStack is : \";\n    while(!s1.empty())\n    {\n    \tint a=s1.top();\n    \ts1.pop();\n    \tcout&lt;&lt;a&lt;&lt;\" \";\n\t}\n    cout &lt;&lt; \"\\ns.pop() : \"; \n    s.pop(); \n    while(!s.empty())\n\t{\n\t\tint a=s.top();\n\t\ts.pop();\n\t\tcout&lt;&lt;a&lt;&lt;\" \";\n\t}\n\tcout&lt;&lt;endl;\n\t\n\t\/\/QUEUE\n\tqueue&lt;int&gt; q,q1;\n    q.push(2);\n    q.push(4);\n    q.push(8);\n    q.push(7);\n    q.push(70);\n \n    cout &lt;&lt; \"\\nq.size() : \" &lt;&lt; q.size();\n    cout &lt;&lt; \"\\nq.front() : \" &lt;&lt; q.front();\n    cout &lt;&lt; \"\\nq.back() : \" &lt;&lt; q.back();\n    \n    q1=q;\/\/assigning q to q1\n    cout&lt;&lt;endl&lt;&lt;\"Queue q is : \";\n    while(q1.empty()==false)\n    {\n    \tint a=q1.front();\n    \tq1.pop();\n    \tcout&lt;&lt;a&lt;&lt;\" \";\n\t}\n \n    cout &lt;&lt; \"\\nq.pop() : \";\n    q.pop();\n    \n \n    \/\/ We can also use front and back as\n    \/\/ iterators to traverse through the queue\n    cout &lt;&lt; \"Using iterators : \";\n    for (auto i = q.front(); i != q.back(); i++) {\n        cout &lt;&lt; i &lt;&lt; \" \";\n    } \n}\n<\/code><\/pre>\n\n\n\n<p>Also Read: <a href=\"https:\/\/www.mygreatlearning.com\/blog\/templates-in-cpp\/\">Templates in C++<\/a><\/p>\n\n\n\n<p><strong>Algorithms<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Algorithms act on container data with some predefined functions, wherein data gets changed for better results, and provide a smooth way for further manipulation.<br><\/li><li>Suppose there are some coins and one has to arrange them in increasing order of their values, so one applies the \u201cstrategy\u201d to place the coins in a row and then swapping their positions to sort them in increasing order, so the \u201cstrategy\u201d or technique one has used can be said as an algorithm which enables to sort the coins.<\/li><\/ul>\n\n\n\n<p>The algorithms are divided into two broad categories:-<\/p>\n\n\n<figure class=\"wp-block-image size-large td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b.png zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b.png\"><img decoding=\"async\" width=\"1024\" height=\"336\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-1024x336.png\" alt=\"\" class=\"wp-image-28295\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-1024x336.png 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-300x98.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-768x252.png 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-696x228.png 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b-150x49.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23b.png 1049w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Non Manipulative Algorithms<\/strong>:-<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>sort(first_iterator,last_iterator)&nbsp; -&gt; It arranges the data in ascending order or in increasing order.<\/li><li>reverse(first_iterator,last_iterator) -&gt; It reverses the arrangement of the elements in the container.<\/li><li>*min_element(first_iterator,last_iterator) -&gt; It returns the minimum value of the vector.<\/li><li>*max_element(first_iterator,last_iterator) -&gt; It returns the maximum value present in the vector.<\/li><li>count(first_iterator,last_iterator,x) -&gt; It returns the number of times \u2018x\u2019 has appeared in the vector.<\/li><li>find(first_iterator,last_iterator,x) -&gt; It returns the pointer to the end of the vector if element \u2018x\u2019 is not present in the vector or returns the position of the target element.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\n#include&lt;algorithm&gt;\n#include&lt;vector&gt;\n\nusing namespace std;\nint main()\n{\n\tvector&lt;int&gt;v;\n\tv.push_back(10);\n\tv.push_back(2);\n\tv.push_back(30);\n\tv.push_back(4);\n\tv.push_back(50);\n\tv.push_back(6);\n\t\n\tcout&lt;&lt;\"Vector is : \";\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n\tcout&lt;&lt;endl;\n\t\n\tcout&lt;&lt;\"Minimum element : \"&lt;&lt;*min_element(v.begin(),v.end())&lt;&lt;endl;\n\tcout&lt;&lt;\"Maximum element : \"&lt;&lt;*max_element(v.begin(),v.end())&lt;&lt;endl;\n\t\n\tcout&lt;&lt;\"After sorting : \";\n\tsort(v.begin(),v.end());\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n\tcout&lt;&lt;endl;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Manipulative Algorithms :-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>arr.erase(position_of_the_element_to_delete) -&gt; It deletes the element whose location is sent as parameter and resizes the vector.<\/li><li>next_permutation(first_iterator,last_iterator) -&gt; It modifies the vector for next permutation.<\/li><li>previous_permutation(first_iterator,last_iterator) -&gt; It modifies the vector to its previous permutation.<\/li><li>arr.erase(unique(arr.begin(),arr.end()),arr.end()) -&gt; It erases all the multiple occurrences of elements in the vector in sorted manner.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\n#include&lt;vector&gt;\n#include&lt;algorithm&gt;\n\nusing namespace std;\nint main()\n{\n\tvector&lt;int&gt;v;\n\tv.push_back(10);\n\tv.push_back(5);\n\tv.push_back(30);\n\tv.push_back(4);\n\tv.push_back(10);\n\tv.push_back(6);\n\t\n\tcout&lt;&lt;\"Vector is : \";\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n\tcout&lt;&lt;endl;\n\t\n\tvector&lt;int&gt;::iterator it=v.begin();\n\t\n\tcout&lt;&lt;\"Vector after removal of 10 : \";\n\tv.erase(it);\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n\t\n\tcout&lt;&lt;endl;\n\tcout&lt;&lt;\"Vector after removal of duplicity : \";\n\tv.erase(unique(v.begin(),v.end()),v.end());\n\tfor(int i=0;i&lt;v.size();i++)\n\tcout&lt;&lt;v&#91;i]&lt;&lt;\" \";\n}\n<\/code><\/pre>\n\n\n\n<p><strong>&nbsp;<\/strong><strong>Iterators<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&nbsp;Iterators are the <strong>\"smart pointers\"<\/strong> that point to the data in the container like pointers do, but help in traversing over complex data structures, which pointers cannot do efficiently.<br><\/li><li>It\u2019s similar to blinking text cursor in editors, while typing they initially appear at the starting and as we type, it automatically shifts itself to the end of the content but can be taken anywhere in the text area.<\/li><\/ul>\n\n\n<figure class=\"wp-block-image size-large td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c.png zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c.png\"><img decoding=\"async\" width=\"1024\" height=\"304\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-1024x304.png\" alt=\"\" class=\"wp-image-28296\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-1024x304.png 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-300x89.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-768x228.png 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-696x207.png 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-1068x317.png 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c-150x45.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/23c.png 1229w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Input Iterator<\/strong>:- All algorithms are sequential\/linear traversing, where every element is traversed only once.<\/li><li><strong>Output Iterator<\/strong>:- They are just like input iterators, but they only assign the elements.<\/li><li><strong>Forward Iterators<\/strong>:- Iterators don't traverse backward rather they traverse in forward direction.<\/li><li><strong>Bidirectional Iterators<\/strong>:- Iterators can traverse in both forward and backward directions.<\/li><li><strong>Random-access Iterator<\/strong>:- Retrieval of data from the container at the specific position in the container.<\/li><\/ul>\n\n\n\n<p>Also Read: <a href=\"https:\/\/www.mygreatlearning.com\/blog\/constructor-in-cpp\/\">Constructor in C++<\/a><\/p>\n\n\n\n<p><strong>&nbsp;<\/strong><strong>Functors<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Functors are \u201cfunction objects\u201d that are passed as arguments and point to those functions that are to be executed.<\/li><li>Functors are mostly used to handle events.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ A C++ program uses transform() in STL to add \n\/\/ 1 to all elements of arr&#91;]\n#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\n   \nint increment(int x) {  return (x+1); }\n   \nint main()\n{\n    int arr&#91;] = {1, 2, 3, 4, 5};\n    int n = sizeof(arr)\/sizeof(arr&#91;0]);\n   \n    \/\/ Apply increment to all elements of\n    \/\/ arr&#91;] and store the modified elements\n    \/\/ back in arr&#91;]\n    transform(arr, arr+n, arr, increment);\n   \n    for (int i=0; i&lt;n; i++)\n        cout &lt;&lt; arr&#91;i] &lt;&lt;\" \";\n   \n    return 0;\n}\n\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"summary\"><strong>Summary<\/strong><\/h3>\n\n\n\n<p>As a programmer one should be well versed in STL to implement the new algorithms, it eliminates the complex looping structures and helps in resolving the extreme real-world problems for world ease.<\/p>\n\n\n\n<p>To go on with STL, The list of templates to be used is given below. This will help in simplifying the reading of code samples and improve your coding skills. The list of templates is as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ntypedef vector&lt; int &gt; vi;\ntypedef vector&lt; vi &gt; vvi;\ntypedef pair&lt; int,int &gt; ii;\n#define sz(a) int((a).size())\n#define pb push_back\n#defile all\u00a9 \u00a9.begin(),\u00a9.end()\n#define tr(c,i) for(typeof(\u00a9).begin() i = \u00a9.begin(); i != \u00a9.end(); i++)\n#define present(c,x) (\u00a9.find(x) != \u00a9.end())\n#define cpresent(c,x) (find(all\u00a9,x) != \u00a9.end())\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc. As a programmer one has to make [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":28145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[],"class_list":["post-28291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Standard Template Library in C++ - Great Learning<\/title>\n<meta name=\"description\" content=\"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Standard Template Library in C++\" \/>\n<meta property=\"og:description\" content=\"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-23T13:08:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-03T05:38:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1254\" \/>\n\t<meta property=\"og:image:height\" content=\"836\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Standard Template Library in C++\",\"datePublished\":\"2021-03-23T13:08:34+00:00\",\"dateModified\":\"2024-09-03T05:38:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/\"},\"wordCount\":985,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/iStock-1255236227.jpg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/\",\"name\":\"Standard Template Library in C++ - Great Learning\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/iStock-1255236227.jpg\",\"datePublished\":\"2021-03-23T13:08:34+00:00\",\"dateModified\":\"2024-09-03T05:38:27+00:00\",\"description\":\"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/iStock-1255236227.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/iStock-1255236227.jpg\",\"width\":1254,\"height\":836,\"caption\":\"capstone project\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/standard-template-library-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Standard Template Library in C++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Standard Template Library in C++ - Great Learning","description":"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Standard Template Library in C++","og_description":"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-03-23T13:08:34+00:00","article_modified_time":"2024-09-03T05:38:27+00:00","og_image":[{"width":1254,"height":836,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Standard Template Library in C++","datePublished":"2021-03-23T13:08:34+00:00","dateModified":"2024-09-03T05:38:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/"},"wordCount":985,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/","url":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/","name":"Standard Template Library in C++ - Great Learning","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg","datePublished":"2021-03-23T13:08:34+00:00","dateModified":"2024-09-03T05:38:27+00:00","description":"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg","width":1254,"height":836,"caption":"capstone project"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/standard-template-library-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Standard Template Library in C++"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg",1254,836,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-768x512.jpg",768,512,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg",1254,836,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227.jpg",1254,836,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-640x836.jpg",640,836,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-96x96.jpg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/iStock-1255236227-150x100.jpg",150,100,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Standard Template Library is the latest edition in C++. STL provides programmers to store the data effectively, and do manipulation in stored data. These are the general-purpose templates of classes and functions that help in implementing the basic algorithms and data structures like vector, lists, queue, stack, etc. As a programmer one has to make&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/28291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=28291"}],"version-history":[{"count":2,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/28291\/revisions"}],"predecessor-version":[{"id":28309,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/28291\/revisions\/28309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/28145"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=28291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=28291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=28291"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=28291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}