All about STL in C++

Salma Hana
2 min readJun 5, 2023

--

C++ like other programming languages have libraries that can help us in programming. One of these libraries is called The Standard Template Library(STL).

About The Library

The STL library was created by Alexander Stepanov in 1994. This library includes algorithms, functions, containers and iterators.

Containers in STL

containers are objects that store a collection of other objects (mostly the same type)

Container available:

  • Sequence Containers : Vector, deque, list
  • Associative Container : map, multi map , set and, multi set.
  • Container Adapter : stack, queue, priority queue

They will be discussed in details later..

Iterators

iterators are objects that can move through element of a container.

Types of Iterators:

  • Input iterators: It only allows us to read the elements of the container without changing its value. This type can only move in one direction, which is by incrementing ( ++ ) and it can’t be decremeneted( — — ).
  • Forward iterators : It allows us to read the elements of the container and change its value. It can only be incremented (++) and it can’t be decrimenet (- -).
  • Bidirectional Iterator : It does the same function as the forward iterator but this type can be decremented ( — — ).
  • Random Access Iterator: It is the same as the bidirectional iterator but it can also be incremented and decremented a certain number of steps.

Algorithms

STL uses different algorithms, such as:

  • sorting: sort, etc..
  • searching : find, binary search, etc..
  • removing/modifying algorithms : remove, copy , etc..
  • numeric algorithms : accumulate.. etc
  • much more

--

--

Salma Hana

I study computer science and I am interested in data science, ai, and machine learning