{"id":259,"date":"2016-01-28T13:20:19","date_gmt":"2016-01-28T10:20:19","guid":{"rendered":"https:\/\/sobbayi.com\/?p=259"},"modified":"2024-02-20T17:49:08","modified_gmt":"2024-02-20T14:49:08","slug":"cplusplus-standard-template-library-unordered-associative-containers-part-5","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/cplusplus-standard-template-library-unordered-associative-containers-part-5\/","title":{"rendered":"The C++ Standard Template Library Unordered Associative Containers – Part 5"},"content":{"rendered":"

We are now down to the fifth part in our series on the C++ Standard Template Library. Today we shall be dealing with the unordered associative containers.<\/p>\n

These unordered containers include the unordered Set or Multiset and the Unordered Map or Multimap. If you have no clue what those mean you can check out this this link and read about the associative containers<\/a>.<\/p>\n

Just in case you don’t know what the C++ Standard Template Library (STL) is you can go to the start of this series and play catch up<\/a>. It is easy reading with examples and by the time you get back here you will be in good shape.<\/p>\n

As usual this article assumes you have prior knowledge of the C++ programming language as well as a good understanding of STL from the previous articles in this series. So lets get started.<\/p>\n

What are the Unordered Associative Containers?<\/h2>\n

Unordered Associative Containers are generally introduced in C++11. These are simply associative containers whereby the order of the elements within those containers are not defined.<\/p>\n

The implementation of these containers internally is the hash table or an array of linked lists. The general term is an array of buckets with a list of entries. The hash function is used to determine the value of an element which is then placed in an entry based on the the value of the element.<\/p>\n

Finding an element in unordered associative containers takes constant time which is generally the fastest possible of the various search methods.<\/p>\n

\"Unordered<\/a><\/p>\n

Here is some code illustrating the use of the unordered set:<\/p>\n