{"id":34028,"date":"2024-08-30T01:48:26","date_gmt":"2024-08-30T05:48:26","guid":{"rendered":"https:\/\/statanalytica.com\/blog\/?p=34028"},"modified":"2024-08-30T01:48:34","modified_gmt":"2024-08-30T05:48:34","slug":"c-plus-plus-dictionary","status":"publish","type":"post","link":"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/","title":{"rendered":"Mastering C++ Dictionary: A Quick and Easy Guide"},"content":{"rendered":"\n<p>In C++ dictionary is a helpful tool for handling data. It lets you connect unique keys with specific values, making it easy to find and organize information. This is handy when you need to match things like usernames with profiles or product codes with details. Unlike arrays that use numbers to access data, a dictionary allows you to use more descriptive keys, like names or custom objects. This makes your code more precise and easier to work with.&nbsp;<\/p>\n\n\n\n<p>In this article, you will learn about the C++ dictionary. How can you create a dictionary using different methods? After going through this article, you can easily create a dictionary and learn about all the details related to the C++ dictionary.\u00a0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"what-is-a-c-dictionary\"><\/span><strong>What is a C++ Dictionary?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a09b3b04354f\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ff5104;color:#ff5104\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ff5104;color:#ff5104\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a09b3b04354f\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#what-is-a-c-dictionary\" >What is a C++ Dictionary?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#1-std-map\" >1. std::map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#how-to-create-a-std-map\" >How to Create a std::map:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#2-std-unordered-map\" >2. std::unordered_map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#how-to-create-a-std-unordered-map\" >How to Create a std::unordered_map:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#ways-to-create-a-c-dictionary\" >Ways to Create a C++ Dictionary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#key-points\" >Key Points<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-by-step-guide-to-creating-a-dictionary-in-c-using-std-map\" >Step-by-Step Guide to Creating a Dictionary in C++ Using std::map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-1-include-the-needed-headers\" >Step 1: Include the Needed Headers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-2-declare-your-std-map\" >Step 2: Declare Your std::map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-3-add-items-to-your-dictionary\" >Step 3: Add Items to Your Dictionary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-4-get-values-by-key\" >Step 4: Get Values by Key<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-5-loop-through-your-dictionary\" >Step 5: Loop Through Your Dictionary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-6-update-values\" >Step 6: Update Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-7-remove-items\" >Step 7: Remove Items<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-8-check-if-a-key-exists\" >Step 8: Check If a Key Exists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-9-clear-the-dictionary\" >Step 9: Clear the Dictionary<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#step-10-compile-and-run-your-code\" >Step 10: Compile and Run Your Code<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#choosing-between-map-and-unordered-map-in-c\" >Choosing Between map and unordered_map in C++<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#1-how-they-store-data\" >1. How They Store Data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#2-when-to-use-map\" >2. When to Use map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#3-when-to-use-unordered-map\" >3. When to Use unordered_map<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#4-memory-usage\" >4. Memory Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#5-performance\" >5. Performance<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#6-examples-of-use\" >6. Examples of Use<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#7-conclusion-which-should-you-use\" >7. Conclusion: Which Should You Use?<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#also-read\" >Also Read<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#final-words\" >Final Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#how-do-i-create-a-dictionary-in-c\" >How do I create a dictionary in C++?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#how-do-i-add-items-to-a-dictionary-in-c\" >How do I add items to a dictionary in C++?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/statanalytica.com\/blog\/c-plus-plus-dictionary\/#how-do-i-get-a-value-from-a-dictionary-in-c\" >How do I get a value from a dictionary in C++?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>In C++, a dictionary is a way to store data in pairs, each pair consisting of a unique key and a value. This makes it easy to find a value if you know the key. C++ doesn&#8217;t have a built-in dictionary, but you can use<strong> <\/strong><strong>std::map<\/strong> or <strong>std::unordered_map<\/strong> to create one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1-std-map\"><\/span><strong>1. <\/strong><strong>std::map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>What It Is<\/strong>: std::map is a container that keeps key-value pairs sorted by the key. This means that when you add items, they will be organized in order.<\/p>\n\n\n\n<p><strong>Key Features<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Order<\/strong>: Keys are kept in a sorted order.<\/li>\n\n\n\n<li><strong>Implementation<\/strong>: Uses a type of tree to manage the data.<\/li>\n\n\n\n<li><strong>Performance<\/strong>: Adding, removing, or finding items takes O(log n) time, where n = number of items.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<p>#include &lt;iostream&gt;<\/p>\n\n\n\n<p>#include &lt;map&gt;<\/p>\n\n\n\n<p>int main() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Create a map with int values and string keys<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::map&lt;std::string, int&gt; dictionary;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Add key-value pairs<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Coke&#8221;] = 1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Sprite&#8221;] = 2;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Pepsi&#8221;] = 3;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Access values by key<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Coke: &#8221; &lt;&lt; dictionary[&#8220;Coke&#8221;] &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Sprite: &#8221; &lt;&lt; dictionary[&#8220;Sprite&#8221;] &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Loop through the map<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;for (const auto&amp; pair: dictionary) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; pair.first &lt;&lt; &#8220;: &#8221; &lt;&lt; pair.second &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"how-to-create-a-std-map\"><\/span><strong>How to Create a <\/strong><strong>std::map<\/strong><strong>:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>Default Constructor<\/strong>: Creates an empty map.<br><br>std::map&lt;std::string, int&gt; myMap;<\/p>\n\n\n\n<p><strong>Initialization List<\/strong>: Creates the map with some key-value pairs.<br><br>std::map&lt;std::string, int&gt; myMap = { {&#8220;Coke&#8221;, 1}, {&#8220;Sprite&#8221;, 2}, {&#8220;Pepsi&#8221;, 3} };<\/p>\n\n\n\n<p><strong>Using <\/strong><strong>insert<\/strong><strong> Method<\/strong>: Adds items to an existing map.<br><br>myMap.insert(std::make_pair(&#8220;Coke&#8221;, 1));<\/p>\n\n\n\n<p>myMap.insert({&#8220;Sprite&#8221;, 2});<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-std-unordered-map\"><\/span><strong>2. <\/strong><strong>std::unordered_map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>What It Is<\/strong>: std::unordered_map is a container that stores key-value pairs without any specific order. It uses a hash table to find items quickly.<\/p>\n\n\n\n<p><strong>Key Features<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Order<\/strong>: Keys are not sorted.<\/li>\n\n\n\n<li><strong>Implementation<\/strong>: Uses a hash table for fast access.<\/li>\n\n\n\n<li><strong>Performance<\/strong>: Adding, removing, or finding items usually takes O(1) time, but it can be slower if there are many collisions.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<p>#include &lt;iostream&gt;<\/p>\n\n\n\n<p>#include &lt;unordered_map&gt;<\/p>\n\n\n\n<p>int main() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Create an unordered_map with string keys and int values<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::unordered_map&lt;std::string, int&gt; dictionary;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Add key-value pairs<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Coke&#8221;] = 1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Sprite&#8221;] = 2;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;dictionary[&#8220;Pepsi&#8221;] = 3;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Access values by key<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Coke: &#8221; &lt;&lt; dictionary[&#8220;Coke&#8221;] &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Sprite: &#8221; &lt;&lt; dictionary[&#8220;Sprite&#8221;] &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Loop through the unordered_map<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;for (const auto&amp; pair : dictionary) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; pair.first &lt;&lt; &#8220;: &#8221; &lt;&lt; pair.second &lt;&lt; std::endl;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"how-to-create-a-std-unordered-map\"><\/span><strong>How to Create a <\/strong><strong>std::unordered_map<\/strong>:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>Default Constructor<\/strong>: Creates an empty unordered_map.<br><br>std::unordered_map&lt;std::string, int&gt; myUnorderedMap;<\/p>\n\n\n\n<p><strong>Initialization List<\/strong>: Creates the unordered_map with some key-value pairs.<br><br>std::unordered_map&lt;std::string, int&gt; myUnorderedMap = { {&#8220;Coke&#8221;, 1}, {&#8220;Sprite&#8221;, 2}, {&#8220;Pepsi&#8221;, 3} };<\/p>\n\n\n\n<p><strong>Using the <\/strong><strong>emplace<\/strong><strong> Method<\/strong>: Adds items efficiently.<br><br>myUnorderedMap.emplace(&#8220;Coke&#8221;, 1);<\/p>\n\n\n\n<p>myUnorderedMap.emplace(&#8220;Sprite&#8221;, 2);<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ways-to-create-a-c-dictionary\"><\/span><strong>Ways to Create a C++ Dictionary<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Default Constructor<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Start with an empty dictionary and add key-value pairs later.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><br>std::map&lt;std::string, int&gt; myMap;<\/p>\n\n\n\n<p>std::unordered_map&lt;std::string, int&gt; myUnorderedMap;<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Initialization List<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Create the dictionary with key-value pairs right away.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><br>std::map&lt;std::string, int&gt; myMap = { {&#8220;Coke&#8221;, 1}, {&#8220;Sprite&#8221;, 2}, {&#8220;Pepsi&#8221;, 3} };<\/p>\n\n\n\n<p>std::unordered_map&lt;std::string, int&gt; myUnorderedMap = { {&#8220;Coke&#8221;, 1}, {&#8220;Sprite&#8221;, 2}, {&#8220;Pepsi&#8221;, 3} };<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Using <\/strong><strong>insert<\/strong><strong> Method<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Add key-value pairs to an existing dictionary.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><br>std::map&lt;std::string, int&gt; myMap;<\/p>\n\n\n\n<p>myMap.insert(std::make_pair(&#8220;Coke&#8221;, 1));<\/p>\n\n\n\n<p>myMap.insert({&#8220;Sprite&#8221;, 2});<\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Using <\/strong><strong>emplace<\/strong><strong> Method<\/strong> (for std::unordered_map):\n<ul class=\"wp-block-list\">\n<li>Efficiently add key-value pairs.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><br>std::unordered_map&lt;std::string, int&gt; myUnorderedMap;<\/p>\n\n\n\n<p>myUnorderedMap.emplace(&#8220;Coke&#8221;, 1);<\/p>\n\n\n\n<p>myUnorderedMap.emplace(&#8220;Sprite&#8221;, 2);<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"key-points\"><\/span><strong>Key Points<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Key-Value Pair<\/strong>: Each item in the dictionary has a unique key that maps to a value.<\/li>\n\n\n\n<li><strong>Accessing Values<\/strong>: Get a value by using its key, like a dictionary[&#8220;key&#8221;].<\/li>\n\n\n\n<li><strong>Insertion<\/strong>: Add items to the dictionary using = or methods like insert and emplace.<\/li>\n\n\n\n<li><strong>Iteration<\/strong>: You can loop through both std::map and std::unordered_map, but std::unordered_map does not guarantee the order of items.<\/li>\n<\/ul>\n\n\n\n<p>Choose std::map if you need to sort items. Choose std::unordered_map if you want faster access times without caring about the order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-by-step-guide-to-creating-a-dictionary-in-c-using-std-map\"><\/span><strong>Step-by-Step Guide to Creating a Dictionary in C++ Using <\/strong><strong>std::map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Creating a dictionary in C++ is simple when you use the std::map from the Standard Template Library (STL). Here\u2019s an easy guide to help you get started.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-1-include-the-needed-headers\"><\/span><strong>Step 1: Include the Needed Headers<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First, you need to include some headers in your program to use std::map.<\/p>\n\n\n\n<p>#include &lt;iostream&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>#include &lt;map&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>#include &lt;string&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-2-declare-your-std-map\"><\/span><strong>Step 2: Declare Your <\/strong><strong>std::map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Next, declare a std::map that will be your dictionary. You\u2019ll need to specify the types of keys and values.<\/p>\n\n\n\n<p>std::map&lt;std::string, int&gt; dictionary;<\/p>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>std::string<\/strong> is used for the keys (like the names of fruits).<\/li>\n\n\n\n<li><strong>Int<\/strong> is used for the values (like the quantities).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-3-add-items-to-your-dictionary\"><\/span><strong>Step 3: Add Items to Your Dictionary<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can add items (key-value pairs) to your std::map using either the [] operator or the insert() method.<\/p>\n\n\n\n<p><strong>Using the <\/strong><strong>[]<\/strong><strong> Operator<\/strong>:<\/p>\n\n\n\n<p>dictionary[&#8220;Pepsi&#8221;] = 10;<\/p>\n\n\n\n<p>dictionary[&#8220;coke&#8221;] = 5;<\/p>\n\n\n\n<p>dictionary[&#8220;Sprite&#8221;] = 20;<\/p>\n\n\n\n<p><strong>Using the <\/strong><strong>insert()<\/strong><strong> Method<\/strong>:<\/p>\n\n\n\n<p>dictionary.insert(std::make_pair(&#8220;Pepsi&#8221;, 10));<\/p>\n\n\n\n<p>dictionary.insert({&#8220;coke&#8221;, 5});<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-4-get-values-by-key\"><\/span><strong>Step 4: Get Values by Key<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To get the value associated with a key, just use the [] operator.<\/p>\n\n\n\n<p>int PepsiQuantity = dictionary[&#8220;Pepsi&#8221;];<\/p>\n\n\n\n<p>std::cout &lt;&lt; &#8220;Pepsi quantity: &#8221; &lt;&lt; PepsiQuantity &lt;&lt; std::endl;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-5-loop-through-your-dictionary\"><\/span><strong>Step 5: Loop Through Your Dictionary<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To see all the items in your dictionary, use a simple for loop.<\/p>\n\n\n\n<p>for (const auto&amp; pair : dictionary) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; pair.first &lt;&lt; &#8220;: &#8221; &lt;&lt; pair.second &lt;&lt; std::endl;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>This loop will print out each key and its matching value.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-6-update-values\"><\/span><strong>Step 6: Update Values<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to change the value for a specific key, just use the [] operator again.<\/p>\n\n\n\n<p>dictionary[&#8220;coke&#8221;] = 7;&nbsp; \/\/ Update the quantity of coke<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-7-remove-items\"><\/span><strong>Step 7: Remove Items<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To delete an item from your dictionary, use the erase() method.<\/p>\n\n\n\n<p>dictionary.erase(&#8220;Sprite&#8221;);&nbsp; \/\/ Remove the &#8220;Sprite&#8221; item<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-8-check-if-a-key-exists\"><\/span><strong>Step 8: Check If a Key Exists<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To find out if a particular key is in your dictionary, use the find() method.<\/p>\n\n\n\n<p>if (dictionary.find(&#8220;Pepsi&#8221;) != dictionary.end()) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Pepsi is in the dictionary.&#8221; &lt;&lt; std::endl;<\/p>\n\n\n\n<p>} else {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; &#8220;Pepsi is not in the dictionary.&#8221; &lt;&lt; std::endl;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-9-clear-the-dictionary\"><\/span><strong>Step 9: Clear the Dictionary<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to remove everything from your dictionary, use the precise () method.<\/p>\n\n\n\n<p>dictionary.clear();<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"step-10-compile-and-run-your-code\"><\/span><strong>Step 10: Compile and Run Your Code<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Once your code is ready, compile it and run the program to see the results.<\/p>\n\n\n\n<p>g++ your_program.cpp -o your_program<\/p>\n\n\n\n<p>.\/your_program<\/p>\n\n\n\n<p>Reading these steps will allow you to create and manage a dictionary in C++ using std::mly easily. This guide gives you the basics to start building more complex programs as you become more comfortable with C++.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"choosing-between-map-and-unordered-map-in-c\"><\/span><strong>Choosing Between <\/strong><strong>map<\/strong><strong> and <\/strong><strong>unordered_map<\/strong><strong> in C++<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When you work with key-value pairs in C++, you often need to decide between using a map or an unordered map. Both are useful but in different ways. Here&#8217;s a simple guide to help you choose the right one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1-how-they-store-data\"><\/span><strong>1. How They Store Data<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>map<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>How It Works<\/strong>: It uses a <strong>Balanced Binary Tree<\/strong> (like a Red-Black Tree).<\/li>\n\n\n\n<li><strong>Order<\/strong>: It keeps everything <strong>sorted by the key<\/strong>.<\/li>\n\n\n\n<li><strong>Speed<\/strong>: Adding, removing, and searching take <strong>O(log n)<\/strong> time.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>unordered_map<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>How It Works<\/strong>: It uses a <strong>Hash Table<\/strong>.<\/li>\n\n\n\n<li><strong>Order<\/strong>: There\u2019s <strong>no specific order<\/strong>; it\u2019s all about being fast.<\/li>\n\n\n\n<li><strong>Speed<\/strong>: Usually, it\u2019s very fast with <strong>O(1)<\/strong> time for most operations. But sometimes, if things get complicated, it can slow down to <strong>O(n)<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-when-to-use-map\"><\/span><strong>2. When to Use <\/strong><strong>map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Need for Order<\/strong>: If you need your data <strong>sorted<\/strong> (like keeping names in alphabetical order), choose the map.<\/li>\n\n\n\n<li><strong>Range-Based Operations<\/strong>: If you need to find items within a specific range, the map is the way to go.<\/li>\n\n\n\n<li><strong>Memory Efficiency<\/strong>: map generally uses less memory because it doesn\u2019t need extra space for handling hash problems.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-when-to-use-unordered-map\"><\/span><strong>3. When to Use <\/strong><strong>unordered_map<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fast Lookups<\/strong>: If you want <strong>quick<\/strong> searches and don\u2019t care about order, unordered_map is your best option.<\/li>\n\n\n\n<li><strong>Frequent Updates<\/strong>: Great for situations where you\u2019re often adding or removing items.<\/li>\n\n\n\n<li><strong>Large Datasets<\/strong>: Perfect for handling large amounts of data where speed is critical and order isn\u2019t necessary.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4-memory-usage\"><\/span><strong>4. Memory Usage<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>map<\/strong>: Uses a tree structure, which is usually more memory-efficient.<\/li>\n\n\n\n<li><strong>unordered_map<\/strong>: Needs more memory because of the hash table, which includes extra space to manage possible collisions.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5-performance\"><\/span><strong>5. Performance<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>map<\/strong>: Always gives you O(log n) time for all operations, making it reliable no matter how many elements you have.<\/li>\n\n\n\n<li><strong>unordered_map<\/strong>: Usually fast with O(1) time, but can slow down to O(n) if many keys hash to the same value.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6-examples-of-use\"><\/span><strong>6. Examples of Use<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>map<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Use it when you need to keep data in order, like a phone book sorted by name.<\/li>\n\n\n\n<li>It\u2019s also good for situations where you need to go through items in order.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>unordered_map<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Ideal for tasks like counting how many times a word appears where order doesn\u2019t matter.<\/li>\n\n\n\n<li>It is great for quick access to data, like in a caching system, where speed is more important than order.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7-conclusion-which-should-you-use\"><\/span><strong>7. Conclusion: Which Should You Use?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Choose <\/strong><strong>map<\/strong> if:\n<ul class=\"wp-block-list\">\n<li>You need the items to stay in order.<\/li>\n\n\n\n<li>You want consistent performance without worrying about how the data is stored.<\/li>\n\n\n\n<li>Your task requires ordered data or needs to find items within a range.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Choose <\/strong><strong>unordered_map<\/strong> if:\n<ul class=\"wp-block-list\">\n<li>You need the fastest searches possible and don\u2019t care about the order.<\/li>\n\n\n\n<li>You\u2019re working with large datasets and want efficient performance.<\/li>\n\n\n\n<li>The order isn\u2019t necessary, and you\u2019re okay with handling hash collisions if they occur.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Understanding the differences between map and unordered_map can help you choose the correct method for your needs and ensure that your code runs smoothly.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"also-read\"><\/span>Also Read<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/statanalytica.com\/blog\/7-highest-paying-programming-languages-2024\/\">7 Highest Paying Programming Languages 2024<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/statanalytica.com\/blog\/7-most-in-demand-programming-languages-for-2024\/\">7 Most In-demand Programming Languages for 2024<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"final-words\"><\/span><strong>Final Words<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In C++, there isn&#8217;t a built-in &#8220;dictionary&#8221; type, but you can still manage key-value pairs effectively. A C++ dictionary lets you store and access data using keys. The way you handle this data depends on your needs, whether it&#8217;s keeping things in order or accessing data quickly.<\/p>\n\n\n\n<p>Knowing how to use these tools can help you handle key-value data efficiently and keep your programs running smoothly.<\/p>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1724996082598\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><span class=\"ez-toc-section\" id=\"how-do-i-create-a-dictionary-in-c\"><\/span><strong>How do I create a dictionary in C++?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>You create a dictionary using std::map or std::unordered_map. Both let you store pairs of keys and values, but they do things a bit differently.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1724996221141\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><span class=\"ez-toc-section\" id=\"how-do-i-add-items-to-a-dictionary-in-c\"><\/span><strong>How do I add items to a dictionary in C++?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>To add items:<br \/>For map: myMap[key] = value;<br \/>For unordered_map: myUnorderedMap[key] = value;<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1724996248622\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><span class=\"ez-toc-section\" id=\"how-do-i-get-a-value-from-a-dictionary-in-c\"><\/span><strong>How do I get a value from a dictionary in C++?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>To get a value:<br \/>For map: value = myMap[key];<br \/>For unordered_map: value = my<a href=\"https:\/\/cplusplus.com\/reference\/unordered_map\/unordered_map\/\" target=\"_blank\" rel=\"noreferrer noopener\">UnorderedMap<\/a>[key];<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>In C++ dictionary is a helpful tool for handling data. It lets you connect unique keys with specific values, making it easy to find and organize information. This is handy when you need to match things like usernames with profiles or product codes with details. Unlike arrays that use numbers to access data, a dictionary [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":34033,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","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":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"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":""},"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":[136],"tags":[3958],"class_list":["post-34028","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","tag-mastering-c-dictionary-a-quick-and-easy-guide"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts\/34028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/comments?post=34028"}],"version-history":[{"count":1,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts\/34028\/revisions"}],"predecessor-version":[{"id":34034,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/posts\/34028\/revisions\/34034"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/media\/34033"}],"wp:attachment":[{"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/media?parent=34028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/categories?post=34028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statanalytica.com\/blog\/wp-json\/wp\/v2\/tags?post=34028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}