Standard Template Library

  1. STL is a Software library designed by Alexander Stepanoy for C++ Programminf language.

  2. It Provides 4 components:

    1. Algorithms

    2. Containers

    3. Functions

    4. Iterators

    5. Allocators

  3. STL is set of Common Classes for C++, such as containes and associative arrays, that can be used with any built-in type and with any user-defined type.

  4. STL achives its results through the use of templates. This approach provides compile-time polymorphism that is often more efficient than run-time polymorphism.


The main components of STL Library

  1. Containers : in C++ STL are used to store and manage collections of objects, offering various ways to organize and access data with built-in manipulation functionalities. They are categorized into four types:

    1. Sequence Containers (e.g., vector, list, deque) that store elements in sequential order;

    2. Associative Containers (e.g., set, map, multiset, multimap) that allow fast retrieval based on keys;

    3. Unordered Associative Containers (e.g., unordered_set, unordered_map) that provide average constant time complexity for lookups;

    4. Container Adaptors (e.g., stack, queue, priority_queue) that offer specific interfaces to other containers.

  2. Algorithms : The STL includes a wide range of algorithms that can be applied to the containers. These algorithms include operations for searching, sorting, modifying, and manipulating data. Examples include sort, find, copy, and accumulate

  3. Iterators : Iterators are objects that provide a way to access the elements of a container sequentially without exposing the underlying representation. They act as a bridge between containers and algorithms, allowing algorithms to work with any container that supports iterators.

  4. Function Objects or Functors : These are objects that can be called as if they were functions. They are often used to customize the behavior of algorithms.

  5. Allocators : The STL provides a mechanism for memory management through allocators, which define how memory is allocated and deallocated for containers.

Last updated