DEV Community

Cover image for STL Standard Template Library
Abdelkader Ould Hennia
Abdelkader Ould Hennia

Posted on

STL Standard Template Library

(STL) is a set of C++ template classes to provide common programming data structures and functions such as
lists, stacks, arrays, etc.

It is a library of container classes, algorithms, and iterators.

It is a generalized library and so, its components are parameterized. Working knowledge of template classes is a prerequisite for working with STL.

(STL) is a collection of algorithms, data structures, and other components that can be used to simplify the development of C++ programs

(STL) Provide to write generic, reusable code that can be applied to different data types. This means that you can write an algorithm once

STL has 4 components:

Algorithms
Containers
Functors
Iterators

1. Algorithms
The header algorithm defines a collection of functions specially designed to be used on a range of elements. They act on containers and provide means for various operations for the contents of the containers.

  1. Algorithm
  2. Sorting
  3. Searching
  4. Important STL Algorithms
  5. Useful Array algorithms
  6. Partition Operations
  7. Numeric
  8. valarray class

2. Containers
Containers or container classes store objects and data. There are in total seven standards “first-class” container classes and three container adaptor classes and only seven header files that provide access to these containers or container adaptors.

Sequence Containers: implement data structures that can be accessed in a sequential manner.

  1. vector
  2. list
  3. deque
  4. arrays
  5. forward_list( Introduced in C++11)
    Container Adaptors: provide a different interface for sequential containers.

  6. queue

  7. priority_queue

  8. stack
    Associative Containers: implement sorted data structures that can be quickly searched (O(log n) complexity).

  9. set

  10. multiset

  11. map

  12. multimap
    Unordered Associative Containers: implement unordered data structures that can be quickly searched

  13. unordered_set (Introduced in C++11)

  14. unordered_multiset (Introduced in C++11)

  15. unordered_map (Introduced in C++11)

  16. unordered_multimap (Introduced in C++11)

3. Functors

The STL includes classes that overload the function call operator. Instances of such classes are called function objects or functors. Functors allow the working of the associated function to be customized with the help of parameters to be passed. Must Read – Functors

4. Iterators

As the name suggests, iterators are used for working on a sequence of values. They are the major feature that allows generality in STL. Must Read – Iterators

stl #c++ #data_structre #algorithm #standart_tempalte_library

Top comments (0)