{"id":1401,"date":"2025-01-14T09:20:16","date_gmt":"2025-01-14T09:20:16","guid":{"rendered":"https:\/\/cyberenlightener.com\/?page_id=1401"},"modified":"2025-01-25T18:55:22","modified_gmt":"2025-01-25T18:55:22","slug":"c-tutorials","status":"publish","type":"page","link":"https:\/\/cyberenlightener.com\/?page_id=1401","title":{"rendered":"C++ tutorials"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-8-color\"><strong>Vectors<\/strong>&#8211;&gt;<\/mark><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#def\" data-type=\"internal\" data-id=\"#def\">Definition<\/a>, <a href=\"#size\" data-type=\"internal\" data-id=\"#size\">Size<\/a>&amp;<a href=\"#capa\" data-type=\"internal\" data-id=\"#capa\">Capacity<\/a>, <a href=\"#pushpop\" data-type=\"internal\" data-id=\"#pushpop\">Push_Back, Pop_Back<\/a>,<\/li>\n\n\n\n<li><a href=\"#front\" data-type=\"internal\" data-id=\"#front\">Front, Back, at,<\/a><a href=\"#clear\" data-type=\"internal\" data-id=\"#clear\">Clear,<\/a> <a href=\"#empty\" data-type=\"internal\" data-id=\"#empty\">Empty<\/a>, <a href=\"#resize\" data-type=\"internal\" data-id=\"#resize\">Resize<\/a>, <a href=\"#swap\" data-type=\"internal\" data-id=\"#swap\">Swap<\/a>,<\/li>\n\n\n\n<li><strong><a href=\"#lat\" data-type=\"internal\" data-id=\"#lat\">Sort, <span style=\"text-decoration: underline;\">reverse, begin &amp; end <\/span><\/a><\/strong><\/li>\n\n\n\n<li><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\"><a href=\"#stack\" data-type=\"internal\" data-id=\"#stack\">Vector as Stack, Queue &amp; LinkedList using C++ STL<\/a><\/mark><\/strong><\/li>\n\n\n\n<li><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\"><a href=\"#nest\" data-type=\"internal\" data-id=\"#nest\">Nested STL (Standard Template Library)<\/a><\/mark><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MAP&#8211;><\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#MAP\" data-type=\"internal\" data-id=\"#MAP\"><strong>C++ STL <code>map<\/code> Tutorial<\/strong>-part-A<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li id=\"def\">C++ STL (Standard Template Library) is a part of the C++ Standard Library that provides a collection of template classes and functions to facilitate efficient programming. It includes <strong>containers<\/strong> (such as <code>vector<\/code>, <code>list<\/code>, <code>deque<\/code>, <code>map<\/code>, and <code>set<\/code>) that store and manage data, <strong>algorithms<\/strong> (like <code>sort()<\/code>, <code>find()<\/code>, <code>reverse()<\/code>) to perform operations on containers, and <strong>iterators<\/strong> for traversing through containers (e.g., <code>begin()<\/code>, <code>end()<\/code>). STL also offers <strong>function objects<\/strong> (e.g., <code>greater()<\/code>, <code>less()<\/code>) that can be used like functions. The use of templates makes the STL highly generic and reusable, enabling developers to work with different data types without writing custom solutions, promoting efficiency, and reducing development time.\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Let&#8217;s discuss the C++ vector tutorial with examples:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Vector Definition and Declaration<\/mark><\/strong><\/h6>\n\n\n\n<p>This example shows how to declare and initialize a vector in various ways:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\nint main() {\n    \/\/ Create an empty vector\n    vector&lt;int&gt; v;\n    \/\/ Create a vector with 5 elements, initialized to 10\n    vector&lt;int&gt; v2(5, 10);\n    \/\/ Create a vector initialized with a list of values\n    vector&lt;int&gt; v3 = {1, 2, 3, 4, 5};\n    \/\/ Output the values of v3\n    cout &lt;&lt; \"Vector v3: \";\n    for (int i : v3) {\n        cout &lt;&lt; i &lt;&lt; \" \";\n    }\n    cout &lt;&lt; endl;\n    return 0;\n}\n<strong>Output:<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Vector v3: 1 2 3 4 5\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"size\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Vector Size and Capacity<\/mark><\/h6>\n\n\n\n<p>This example demonstrates the difference between <code>size()<\/code> and <code>capacity()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\nint main() {\n    vector&lt;int&gt; v = {1, 2, 3, 4, 5};\n    \/\/ Size of the vector\n    cout &lt;&lt; \"Size: \" &lt;&lt; v.size() &lt;&lt; endl;  \/\/ Output: 5\n    \/\/ Capacity of the vector\n    cout &lt;&lt; \"Capacity: \" &lt;&lt; v.capacity() &lt;&lt; endl;  \/\/ Output may vary, likely 8 or 10\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Example Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Size: 5\nCapacity: 8\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Note: The capacity may vary depending on the implementation, but typically it will be more than or equal to the size. In this case, the <code>capacity()<\/code> might return <code>8<\/code> because the vector can grow beyond the current number of elements.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"pushpop\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Push Back and Pop Back<\/mark><\/strong><\/h6>\n\n\n\n<p>This example shows how to add and remove elements from the vector using <code>push_back()<\/code> and <code>pop_back()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<br>#include &lt;vector&gt;<br>using namespace std;<br>int main() {<br>    vector&lt;int&gt; v;<br>    \/\/ Push elements to the vector<br>    v.push_back(10);<br>    v.push_back(20);<br>    v.push_back(30);<br>    cout &lt;&lt; \"Vector after push_back operations: \";<br>    for (int i : v) {<br>        cout &lt;&lt; i &lt;&lt; \" \";<br>    }<br>    cout &lt;&lt; endl;<br>    \/\/ Pop an element from the vector<br>    v.pop_back();<br>    cout &lt;&lt; \"Vector after pop_back operation: \";<br>    for (int i : v) {<br>        cout &lt;&lt; i &lt;&lt; \" \";<br>    }<br>    cout &lt;&lt; endl;<br>    return 0;<br>}<br><br><br><strong>Output:<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Vector after push_back operations: 10 20 30 \nVector after pop_back operation: 10 20 \n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"front\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Accessing Elements: <code>front()<\/code>, <code>back()<\/code>, and <code>at()<\/code><\/mark><\/strong><\/h6>\n\n\n\n<p>This example demonstrates how to access the first, last, and specific elements using <code>front()<\/code>, <code>back()<\/code>, and <code>at()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; v = {10, 20, 30, 40, 50};\n\n    \/\/ Accessing the first and last elements\n    cout &lt;&lt; \"First element: \" &lt;&lt; v.front() &lt;&lt; endl;  \/\/ Output: 10\n    cout &lt;&lt; \"Last element: \" &lt;&lt; v.back() &lt;&lt; endl;    \/\/ Output: 50\n\n    \/\/ Accessing an element using at()\n    cout &lt;&lt; \"Element at index 2: \" &lt;&lt; v.at(2) &lt;&lt; endl;  \/\/ Output: 30\n\n    try {\n        \/\/ Trying to access an out-of-bounds element\n        cout &lt;&lt; v.at(10) &lt;&lt; endl;  \/\/ Will throw out_of_range exception\n    } catch (const out_of_range&amp; e) {\n        cout &lt;&lt; \"Exception: \" &lt;&lt; e.what() &lt;&lt; endl;  \/\/ Output: out_of_range exception\n    }\n    return 0;\n}\n<strong>Output:<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>First element: 10\nLast element: 50\nElement at index 2: 30\nException: out_of_range\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Other Useful Functions<\/mark><\/strong><\/h6>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"clear\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\"><strong><code>clear()<\/code><\/strong> &#8211; Removes all elements in the vector.<\/mark><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; v = {1, 2, 3, 4, 5};\n\n    \/\/ Clear the vector\n    v.clear();\n    cout &lt;&lt; \"Vector size after clear: \" &lt;&lt; v.size() &lt;&lt; endl;  \/\/ Output: 0\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Vector size after clear: 0\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"empty\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\"><strong><code>empty()<\/code><\/strong> &#8211; Checks if the vector is empty.<\/mark><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; v = {1, 2, 3};\n\n    cout &lt;&lt; \"Is vector empty? \" &lt;&lt; (v.empty() ? \"Yes\" : \"No\") &lt;&lt; endl;  \/\/ Output: No\n    v.clear();\n    cout &lt;&lt; \"Is vector empty? \" &lt;&lt; (v.empty() ? \"Yes\" : \"No\") &lt;&lt; endl;  \/\/ Output: Yes\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is vector empty? No\nIs vector empty? Yes\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"resize\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\"><code>resize()<\/code> &#8211; Resizes the vector to a given number of elements.<\/mark><\/strong><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; v = {1, 2, 3};\n    \/\/ Resize the vector to hold 5 elements\n    v.resize(5);\n    cout &lt;&lt; \"Vector after resizing: \";\n    for (int i : v) {\n        cout &lt;&lt; i &lt;&lt; \" \";\n    }\n    cout &lt;&lt; endl;  \/\/ Output: 1 2 3 0 0\n    return 0;\n}\n<strong>Output:<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Vector after resizing: 1 2 3 0 0\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"swap\"><strong><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">swap() - Swaps the contents of two vectors.<\/mark><\/code><\/strong><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; v1 = {1, 2, 3};\n    vector&lt;int&gt; v2 = {4, 5, 6};\n\n    \/\/ Swap v1 and v2\n    v1.swap(v2);\n\n    cout &lt;&lt; \"Vector v1 after swap: \";\n    for (int i : v1) {\n        cout &lt;&lt; i &lt;&lt; \" \";\n    }\n    cout &lt;&lt; endl;  \/\/ Output: 4 5 6\n\n    cout &lt;&lt; \"Vector v2 after swap: \";\n    for (int i : v2) {\n        cout &lt;&lt; i &lt;&lt; \" \";\n    }\n    cout &lt;&lt; endl;  \/\/ Output: 1 2 3\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Vector v1 after swap: 4 5 6 \nVector v2 after swap: 1 2 3 \n<\/code><\/pre>\n\n\n\n<p id=\"lat\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Sort, reverse, begin &amp; end <\/mark><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;algorithm&gt;  \/\/ for sort, reverse\n#include &lt;functional&gt; \/\/ for greater\nusing namespace std;\nint main() {\n    \/\/ 1. Containers: Create a vector\n    vector&lt;int&gt; v = {3, 1, 2, 5, 4};\n\n    \/\/ 2. Algorithms: Sort the vector in descending order using a function object\n    sort(v.begin(), v.end(), greater&lt;int&gt;());\n\n    \/\/ 3. Iterators: Traverse the vector using an iterator\n    cout &lt;&lt; \"Sorted vector: \";\n    for (auto it = v.begin(); it != v.end(); ++it) {\n        cout &lt;&lt; *it &lt;&lt; \" \";  \/\/ Output: 5 4 3 2 1\n    }\n    cout &lt;&lt; endl;\n\n    \/\/ 4. Algorithms: Reverse the vector\n    reverse(v.begin(), v.end());\n\n    \/\/ 5. Iterators: Traverse again using an iterator\n    cout &lt;&lt; \"Reversed vector: \";\n    for (auto it = v.begin(); it != v.end(); ++it) {\n        cout &lt;&lt; *it &lt;&lt; \" \";  \/\/ Output: 1 2 3 4 5\n    }\n    cout &lt;&lt; endl;\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>Summary<\/strong><\/h6>\n\n\n\n<ul id=\"stack\" class=\"wp-block-list\">\n<li><strong><code>vector<\/code><\/strong> is a sequence container in C++ that dynamically resizes as elements are added or removed.<\/li>\n\n\n\n<li><strong><code>size()<\/code><\/strong> gives the current number of elements, while <strong><code>capacity()<\/code><\/strong> indicates how much memory has been allocated internally.<\/li>\n\n\n\n<li><strong><code>push_back()<\/code><\/strong> adds an element to the end of the vector, while <strong><code>pop_back()<\/code><\/strong> removes the last element.<\/li>\n\n\n\n<li><strong><code>front()<\/code><\/strong>, <strong><code>back()<\/code><\/strong>, and <strong><code>at()<\/code><\/strong> are used to access the first, last, and specific elements in the vector.<\/li>\n\n\n\n<li><strong><code>clear()<\/code><\/strong>, <strong><code>empty()<\/code><\/strong>, <strong><code>resize()<\/code><\/strong>, and <strong><code>swap()<\/code><\/strong> are other useful functions for manipulating the vector.<\/li>\n<\/ul>\n\n\n\n<p>These functions form the foundation for working with vectors in C++ STL.<\/p>\n\n\n\n<p id=\"stack\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Vector as Stack, Queue &amp; LinkedList using C++ STL<\/mark><\/strong><\/p>\n\n\n\n<p>Here\u2019s a short explanation with examples for using <strong>vector as a stack<\/strong>, <strong>queue<\/strong>, and <strong>linked list<\/strong> using <strong>C++ STL<\/strong>:<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Vector as a Stack<\/mark><\/h6>\n\n\n\n<p>A <strong>stack<\/strong> follows the <strong>LIFO (Last In First Out)<\/strong> principle. You can use <code>push_back()<\/code> to add elements and <code>pop_back()<\/code> to remove them.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    vector&lt;int&gt; stack;\n\n    \/\/ Push elements onto the stack\n    stack.push_back(10);\n    stack.push_back(20);\n    stack.push_back(30);\n    \/\/ Pop an element from the stack\n    stack.pop_back();\n    \/\/ Print the stack\n    for (int i : stack) {\n        cout &lt;&lt; i &lt;&lt; \" \";  \/\/ Output: 10 20\n    }\n    cout &lt;&lt; endl;\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Queue Using STL (<code>queue<\/code> container)<\/mark><\/h6>\n\n\n\n<p>A <strong>queue<\/strong> follows the <strong>FIFO (First In First Out)<\/strong> principle. You can use <code>push()<\/code> to add elements and <code>pop()<\/code> to remove them.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;queue&gt;\nusing namespace std;\nint main() {\n    queue&lt;int&gt; q;\n    \/\/ Enqueue elements\n    q.push(10);\n    q.push(20);\n    q.push(30);\n\n    \/\/ Dequeue an element\n    q.pop();\n    \/\/ Print the front element of the queue\n    cout &lt;&lt; \"Front: \" &lt;&lt; q.front() &lt;&lt; endl;  \/\/ Output: 20\n    \/\/ Print the queue size\n    cout &lt;&lt; \"Size: \" &lt;&lt; q.size() &lt;&lt; endl;  \/\/ Output: 2\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Linked List Using STL (<code>list<\/code> container)<\/mark><\/strong><\/h6>\n\n\n\n<p>A <strong>linked list<\/strong> allows efficient insertion and removal at both ends. You can use <code>push_back()<\/code>, <code>push_front()<\/code>, <code>pop_back()<\/code>, <code>pop_front()<\/code>, and <code>insert()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;list&gt;\nusing namespace std;\n\nint main() {\n    list&lt;int&gt; l;\n    \/\/ Insert elements at the back\n    l.push_back(10);\n    l.push_back(20);\n    \/\/ Insert element at the front\n    l.push_front(5);\n\n    \/\/ Remove element from the front\n    l.pop_front();\n\n    \/\/ Remove element from the back\n    l.pop_back();\n\n    \/\/ Print the linked list\n    for (int i : l) {\n        cout &lt;&lt; i &lt;&lt; \" \";  \/\/ Output: 10\n    }\n    cout &lt;&lt; endl;\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Summary of Functions:<\/mark><\/strong><\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Stack (using vector)<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>push_back()<\/code>: Add element to the stack<\/li>\n\n\n\n<li><code>pop_back()<\/code>: Remove element from the stack<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Queue (using <code>queue<\/code> container)<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>push()<\/code>: Add element to the queue<\/li>\n\n\n\n<li><code>pop()<\/code>: Remove element from the queue<\/li>\n\n\n\n<li><code>front()<\/code>: Access the front element<\/li>\n\n\n\n<li><code>back()<\/code>: Access the back element<\/li>\n\n\n\n<li><code>size()<\/code>: Get the size of the queue<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Linked List (using <code>list<\/code> container)<\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>push_back()<\/code>: Add element to the end<\/li>\n\n\n\n<li><code>push_front()<\/code>: Add element to the front<\/li>\n\n\n\n<li><code>pop_back()<\/code>: Remove element from the end<\/li>\n\n\n\n<li><code>pop_front()<\/code>: Remove element from the front<\/li>\n\n\n\n<li><code>insert()<\/code>: Insert element at a specific position<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"nest\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">Nested STL <\/mark><\/strong><\/h6>\n\n\n\n<pre id=\"nested\" class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;set&gt;\n#include &lt;map&gt;\n#include &lt;unordered_map&gt;\nint main() {\n    \/\/ 1. Vector of Vectors: Used to represent a 2D matrix or grid.\n    std::vector&lt;std::vector&lt;int&gt;&gt; matrix = { \/\/ Declaring a vector where each element is another vector.\n        {1, 2, 3}, \/\/ First row of the matrix.\n        {4, 5, 6}, \/\/ Second row of the matrix.\n        {7, 8, 9}  \/\/ Third row of the matrix.\n    };\n    std::cout &lt;&lt; \"Vector of Vectors:\" &lt;&lt; std::endl;\n    for (const auto&amp; row : matrix) { \/\/ Loop through each row (a vector) in the matrix.\n        for (int value : row) { \/\/ Loop through each value in the current row.\n            std::cout &lt;&lt; value &lt;&lt; \" \"; \/\/ Print the value followed by a space.\n        }\n        std::cout &lt;&lt; std::endl; \/\/ Print a newline after each row.\n    }\n    \/\/ 2. Set of Pairs: Used to store unique pairs of integers, useful for coordinate-like data.\n    std::set&lt;std::pair&lt;int, int&gt;&gt; points = {{1, 2}, {3, 4}, {5, 6}}; \/\/ Declare a set of pairs and initialize it with some values.\n    std::cout &lt;&lt; \"\\nSet of Pairs:\" &lt;&lt; std::endl;\n    for (const auto&amp; point : points) { \/\/ Loop through each pair in the set.\n        std::cout &lt;&lt; \"(\" &lt;&lt; point.first &lt;&lt; \", \" &lt;&lt; point.second &lt;&lt; \")\" &lt;&lt; std::endl; \/\/ Access and print the pair using `first` and `second`.\n    }\n\n    \/\/ 3. Map of Sets: Used to group unique elements (sets) under specific keys.\n    std::map&lt;std::string, std::set&lt;int&gt;&gt; studentSubjects; \/\/ Declare a map where keys are strings and values are sets of integers.\n    studentSubjects&#91;\"Alice\"] = {101, 102, 103}; \/\/ Assign a set of subject codes to \"Alice\".\n    studentSubjects&#91;\"Bob\"] = {102, 104};       \/\/ Assign a set of subject codes to \"Bob\".\n    std::cout &lt;&lt; \"\\nMap of Sets:\" &lt;&lt; std::endl;\n    for (const auto&amp; pair : studentSubjects) { \/\/ Loop through each key-value pair in the map.\n        std::cout &lt;&lt; pair.first &lt;&lt; \": \"; \/\/ Print the key (student name).\n        for (int subject : pair.second) { \/\/ Loop through the set of subject codes.\n            std::cout &lt;&lt; subject &lt;&lt; \" \"; \/\/ Print each subject code.\n        }\n        std::cout &lt;&lt; std::endl; \/\/ Print a newline after each student's subjects.\n    }\n\n    \/\/ 4. Map of Vectors: Used to store lists of values (vectors) under each key.\n    std::map&lt;std::string, std::vector&lt;int&gt;&gt; studentScores; \/\/ Declare a map where keys are strings and values are vectors of integers.\n    studentScores&#91;\"Alice\"] = {90, 85, 88}; \/\/ Assign a vector of scores to \"Alice\".\n    studentScores&#91;\"Bob\"] = {78, 82};       \/\/ Assign a vector of scores to \"Bob\".\n    std::cout &lt;&lt; \"\\nMap of Vectors:\" &lt;&lt; std::endl;\n    for (const auto&amp; pair : studentScores) { \/\/ Loop through each key-value pair in the map.\n        std::cout &lt;&lt; pair.first &lt;&lt; \": \"; \/\/ Print the key (student name).\n        for (int score : pair.second) { \/\/ Loop through the vector of scores.\n            std::cout &lt;&lt; score &lt;&lt; \" \"; \/\/ Print each score.\n        }\n        std::cout &lt;&lt; std::endl; \/\/ Print a newline after each student's scores.\n    }\n\n    \/\/ 5. Unordered Map of Unordered Sets: Used to represent fast lookups, such as a graph adjacency list.\n    std::unordered_map&lt;int, std::unordered_set&lt;int&gt;&gt; graph; \/\/ Declare an unordered map where keys are integers and values are unordered sets of integers.\n    graph&#91;1] = {2, 3}; \/\/ Add edges from node 1 to nodes 2 and 3.\n    graph&#91;2] = {1, 4}; \/\/ Add edges from node 2 to nodes 1 and 4.\n    std::cout &lt;&lt; \"\\nUnordered Map of Unordered Sets (Graph Representation):\" &lt;&lt; std::endl;\n    for (const auto&amp; pair : graph) { \/\/ Loop through each key-value pair in the map.\n        std::cout &lt;&lt; pair.first &lt;&lt; \" -&gt; \"; \/\/ Print the key (a node in the graph).\n        for (int neighbor : pair.second) { \/\/ Loop through the set of neighbors.\n            std::cout &lt;&lt; neighbor &lt;&lt; \" \"; \/\/ Print each neighbor.\n        }\n        std::cout &lt;&lt; std::endl; \/\/ Print a newline after each node's neighbors.\n    }\n\n    return 0; \/\/ Indicate successful execution.\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>C++ STL <code>map<\/code> Tutorial<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>In C++, the Standard Template Library (STL) provides several useful container classes, and one of the most commonly used is the <strong><code>map<\/code><\/strong>. A <code>map<\/code> is an associative container that stores key-value pairs. It is similar to a dictionary or hash table in other programming languages.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>Key Properties of a <code>map<\/code>:<\/strong><\/h6>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Associative<\/strong>: Elements in a <code>map<\/code> are stored as key-value pairs.<\/li>\n\n\n\n<li><strong>Unique Keys<\/strong>: Each key in the <code>map<\/code> must be unique. If you try to insert a duplicate key, it will overwrite the existing value.<\/li>\n\n\n\n<li><strong>Ordered<\/strong>: The elements in the <code>map<\/code> are always stored in a sorted order based on the key. The default sorting is in ascending order, but this can be customized.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax<\/strong>:<\/h3>\n\n\n\n<pre id=\"MAP\" class=\"wp-block-code\"><code>#include &lt;map&gt;\n\n\/\/ Declaration of a map\nmap&lt;KeyType, ValueType&gt; mapName;\n<\/code><\/pre>\n\n\n\n<p>Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>KeyType<\/code>: Type of the key (e.g., <code>int<\/code>, <code>string<\/code>).<\/li>\n\n\n\n<li><code>ValueType<\/code>: Type of the value associated with the key.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>1. Basic Operations on <code>map<\/code><\/strong><\/h6>\n\n\n\n<h6 class=\"wp-block-heading\">1.1 <strong>Creating a <code>map<\/code><\/strong><\/h6>\n\n\n\n<p>A <code>map<\/code> can be created by specifying the key type and value type. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>map&lt;int, string&gt; studentGrades;\n<\/code><\/pre>\n\n\n\n<p>This creates a map where the key is of type <code>int<\/code> (e.g., student ID) and the value is of type <code>string<\/code> (e.g., grade).<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">1.2 <strong>Inserting Elements into a <code>map<\/code><\/strong><\/h6>\n\n\n\n<p>There are two ways to insert elements into a map:<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Using <code>operator[]<\/code>:<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>studentGrades&#91;101] = \"A\";  \/\/ Inserting key-value pair (101, \"A\")\nstudentGrades&#91;102] = \"B\";  \/\/ Inserting key-value pair (102, \"B\")\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">Using <code>insert()<\/code> method:<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>studentGrades.insert({103, \"C\"});  \/\/ Inserting using a pair\nstudentGrades.insert(make_pair(104, \"A\"));\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">1.3 <strong>Accessing Elements<\/strong><\/h6>\n\n\n\n<p>You can access values in a <code>map<\/code> by using the key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cout &lt;&lt; studentGrades&#91;101] &lt;&lt; endl;  \/\/ Output: A\n<\/code><\/pre>\n\n\n\n<p>Note that if the key does not exist, the <code>operator[]<\/code> will insert a default value. To check if a key exists before accessing, use <code>find()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (studentGrades.find(105) != studentGrades.end()) {\n    cout &lt;&lt; studentGrades&#91;105] &lt;&lt; endl;\n} else {\n    cout &lt;&lt; \"Key not found!\" &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">1.4 <strong>Size of a <code>map<\/code><\/strong><\/h3>\n\n\n\n<p>The size of a <code>map<\/code> (number of elements) can be obtained using the <code>size()<\/code> method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cout &lt;&lt; \"Size of map: \" &lt;&lt; studentGrades.size() &lt;&lt; endl;\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">1.5 <strong>Erasing Elements<\/strong><\/h6>\n\n\n\n<p>You can remove elements using the <code>erase()<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>studentGrades.erase(101);  \/\/ Removes the element with key 101\n<\/code><\/pre>\n\n\n\n<p>You can also remove elements using iterators:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>auto it = studentGrades.find(102);\nif (it != studentGrades.end()) {\n    studentGrades.erase(it);\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>2. Iterating Over a <code>map<\/code><\/strong><\/h6>\n\n\n\n<h6 class=\"wp-block-heading\">2.1 <strong>Using Iterator<\/strong><\/h6>\n\n\n\n<p>To iterate over a <code>map<\/code>, you can use an iterator:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (auto it = studentGrades.begin(); it != studentGrades.end(); ++it) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; it-&gt;first &lt;&lt; \", Grade: \" &lt;&lt; it-&gt;second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">2.2 <strong>Using Range-based For Loop<\/strong><\/h6>\n\n\n\n<p>Since C++11, you can also use a range-based for loop for simpler iteration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (const auto&amp; entry : studentGrades) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; entry.first &lt;&lt; \", Grade: \" &lt;&lt; entry.second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">2.3 <strong>Reverse Iteration<\/strong><\/h6>\n\n\n\n<p>To iterate in reverse order, you can use <code>rbegin()<\/code> and <code>rend()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (auto it = studentGrades.rbegin(); it != studentGrades.rend(); ++it) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; it-&gt;first &lt;&lt; \", Grade: \" &lt;&lt; it-&gt;second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Advanced <code>map<\/code> Topics<\/strong><\/h2>\n\n\n\n<h6 class=\"wp-block-heading\">3.1 <strong>Custom Sorting (Comparators)<\/strong><\/h6>\n\n\n\n<p>By default, <code>map<\/code> sorts its keys in ascending order. However, you can provide a custom comparator to change the sorting order.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example: Sorting in descending order<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>map&lt;int, string, greater&lt;int&gt;&gt; reverseStudentGrades;\nreverseStudentGrades&#91;101] = \"A\";\nreverseStudentGrades&#91;102] = \"B\";\nreverseStudentGrades&#91;103] = \"A\";\n\nfor (const auto&amp; entry : reverseStudentGrades) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; entry.first &lt;&lt; \", Grade: \" &lt;&lt; entry.second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">3.2 <strong><code>multimap<\/code><\/strong><\/h6>\n\n\n\n<p>A <code>multimap<\/code> allows multiple elements with the same key, unlike <code>map<\/code> where each key is unique. This is useful when you need to store multiple values under the same key.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example:<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>multimap&lt;int, string&gt; studentSubjects;\nstudentSubjects.insert({101, \"Math\"});\nstudentSubjects.insert({101, \"Physics\"});\nstudentSubjects.insert({102, \"Chemistry\"});\n\nfor (const auto&amp; entry : studentSubjects) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; entry.first &lt;&lt; \", Subject: \" &lt;&lt; entry.second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">3.3 <strong><code>map<\/code> with Complex Types (Custom Classes)<\/strong><\/h6>\n\n\n\n<p>You can use custom types (classes or structs) as keys in a <code>map<\/code>. To do so, you need to define how the keys should be compared (usually by overloading the <code>&lt;<\/code> operator).<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example with a custom comparator:<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>struct Student {\n    int id;\n    string name;\n    \n    \/\/ Overload the &lt; operator for comparison\n    bool operator&lt;(const Student&amp; other) const {\n        return id &lt; other.id;\n    }\n};\n\nmap&lt;Student, string&gt; studentInfo;\nstudentInfo&#91;Student{101, \"John\"}] = \"A\";\nstudentInfo&#91;Student{102, \"Jane\"}] = \"B\";\n\nfor (const auto&amp; entry : studentInfo) {\n    cout &lt;&lt; \"ID: \" &lt;&lt; entry.first.id &lt;&lt; \", Name: \" &lt;&lt; entry.first.name &lt;&lt; \", Grade: \" &lt;&lt; entry.second &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">3.4 <strong>Performance Considerations<\/strong><\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Time Complexity<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Insertion, deletion, and lookup operations all take <strong>O(log n)<\/strong> time because <code>map<\/code> is implemented as a balanced binary search tree (typically Red-Black Tree).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Space Complexity<\/strong>:\n<ul class=\"wp-block-list\">\n<li>The space complexity of a <code>map<\/code> is <strong>O(n)<\/strong>, where <code>n<\/code> is the number of elements stored in the map.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>4. Example: Complete Code of Using <code>map<\/code><\/strong><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    \/\/ 1. Creating a map\n    map&lt;int, string&gt; studentGrades;\n\n    \/\/ 2. Inserting elements\n    studentGrades&#91;101] = \"A\";\n    studentGrades&#91;102] = \"B\";\n    studentGrades.insert({103, \"C\"});\n\n    \/\/ 3. Accessing elements\n    cout &lt;&lt; \"Grade of student with ID 101: \" &lt;&lt; studentGrades&#91;101] &lt;&lt; endl;\n\n    \/\/ 4. Iterating over the map\n    cout &lt;&lt; \"All student grades:\\n\";\n    for (const auto&amp; entry : studentGrades) {\n        cout &lt;&lt; \"ID: \" &lt;&lt; entry.first &lt;&lt; \", Grade: \" &lt;&lt; entry.second &lt;&lt; endl;\n    }\n\n    \/\/ 5. Using custom comparator for reverse sorting\n    map&lt;int, string, greater&lt;int&gt;&gt; reverseMap;\n    reverseMap&#91;101] = \"A\";\n    reverseMap&#91;102] = \"B\";\n    reverseMap&#91;103] = \"C\";\n\n    cout &lt;&lt; \"Reverse sorted map:\\n\";\n    for (const auto&amp; entry : reverseMap) {\n        cout &lt;&lt; \"ID: \" &lt;&lt; entry.first &lt;&lt; \", Grade: \" &lt;&lt; entry.second &lt;&lt; endl;\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">Output:<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>Grade of student with ID 101: A\nAll student grades:\nID: 101, Grade: A\nID: 102, Grade: B\nID: 103, Grade: C\nReverse sorted map:\nID: 103, Grade: C\nID: 102, Grade: B\nID: 101, Grade: A\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>map<\/code><\/strong> is a powerful associative container in C++ STL that stores key-value pairs.<\/li>\n\n\n\n<li>It automatically sorts the keys in ascending order by default, but you can customize the sorting using comparators.<\/li>\n\n\n\n<li>Basic operations include insertion, access, deletion, and iteration.<\/li>\n\n\n\n<li>Advanced topics include custom comparators, multi-maps, and using complex types as keys.<\/li>\n<\/ul>\n\n\n\n<p>.<\/p>\n\n\n\n<p>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vectors&#8211;&gt; MAP&#8211;> Let&#8217;s discuss the C++ vector tutorial with examples: Vector Definition and Declaration This example shows how to declare and initialize a vector in various ways: Vector Size and Capacity This example demonstrates the difference between size() and capacity(). Example Output: Note: The capacity may vary depending on the implementation, but typically it will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"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":""},"class_list":["post-1401","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/pages\/1401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1401"}],"version-history":[{"count":13,"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/pages\/1401\/revisions"}],"predecessor-version":[{"id":1612,"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=\/wp\/v2\/pages\/1401\/revisions\/1612"}],"wp:attachment":[{"href":"https:\/\/cyberenlightener.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}