{"id":261,"date":"2016-02-29T21:27:29","date_gmt":"2016-02-29T18:27:29","guid":{"rendered":"https:\/\/sobbayi.com\/?p=261"},"modified":"2016-02-29T21:27:29","modified_gmt":"2016-02-29T18:27:29","slug":"the-c-standard-template-library-algorithms-and-iterators-part-6","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/the-c-standard-template-library-algorithms-and-iterators-part-6\/","title":{"rendered":"The C++ Standard Template Library Algorithms and Iterators – Part 6"},"content":{"rendered":"

Welcome back to the sixth part in our series on the C++<\/a> Standard Template Library. This time we will be looking at Algorithms and Iterators. If you are new to this series you might want to get started at the beginning by looking at an overview of the C++ Standard Template Library<\/a>.<\/p>\n

Just in case you are already familiar with the basics you can go ahead and read ahead in this article. If you missed it, in our previous tutorial, we talked about the Unordered Associative Containers<\/a> which includes the unordered Set or Multiset and the Unordered Map or Multimap.<\/p>\n

We Start off With Iterators<\/h2>\n

There are five main types of Iterators in the C++ Standard Template Library<\/a> as Follows:<\/p>\n

    \n
  1. Random Access Iterators:<\/strong> as seen earlier used in the array, vector, and deque<\/li>\n
  2. Bidirectional Iterators:<\/strong> these have appeared in the list, set, multiset, map, and multimap<\/li>\n
  3. Forward Iterators:<\/strong> which showed prominently in the forward_list<\/li>\n
  4. Input Iterators:<\/strong> used mainly to read and process values while moving forward only<\/li>\n
  5. Output Iterators:<\/strong> used mainly to output values while moving forward only<\/li>\n<\/ol>\n

    Each container in C++ STL provides an Iterator and a const Iterator. Const Iterators provide read-only access to the containers’ elements:<\/p>\n