What is C++ STL?

R Praveen Kumar
3 min readSep 19, 2020

And why you should learn it?

Chit-Chat:

As a competitive coder, there is a high chance that you may know STL. If you have done programming in C++ and don’t have any idea about STL? Then, the next line might surprise you.

“What if I say, you have already used STL but in a smaller/simpler way”. Let me prove to you the above statement of mine. The arrays and strings we are using are passed to the function as STL objects.

Reasons to learn STL:

STL has four components Introduction:

The 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. C++ STL is a set of data structures and algorithms that we normally encounter during coding.

Algorithms:

The header algorithm defines a lot of commonly used algorithms that we can use out of the box. They provide various operations for containers. Some well-known algorithms are:

  • searching.
  • sorting, etc.
Container Flowchart of STL.

Containers:

Containers or container classes are used to manage collections of objects of a certain kind. There are several different types of containers.

# Sequence Containers: It implements data structures that can be accessed sequentially.

# Associative Containers: They implement sorted data structures that make computation less time costly.

  • unordered_set.
  • unordered_multiset.
  • unordered_map.
  • unordered_multimap.

# Container Adaptors: It provides a different interface for sequential containers.

# Unordered Associative Containers**: It implements unordered data structures that can be quickly searched.

** They are introduced in C++ 11 onwards.

Iterators:

As the name suggests, they are used to iterate through the given sequence or collection of the elements.

Functions:

The STL includes classes that overload the function call operator (operator()). Instances of such classes are called functors or function objects. Functors allow the behavior of the associated function to be parameterized (e.g. through arguments passed to the functor's constructor).

Tips:

The #include<bits/stdc++.h> the header file, contains every STL file, so obviously it takes more compile time. And another thing is if you are going to use only one or two data structures (for ex:- vector and map). There is no sense in accessing the WHOLE file. In a programming contest/event/interview, sometimes the compiler takes a longer time to access this file.

So we are starting a new series on C++ STL. Abhishek and I are going to continue this series. So stay tuned. Hope so, that you got some insight into STL.

Array container in STL Why Paytm App was removed from Google Play Store? Different career options after learning Python NCR Corporation is Hiring 2021 Batch Engineering Graduates | 7 LPA CTC

Your feedbacks are always welcome. Feel free to drop your suggestions in the comment section. Thanks for reading, see you in the next one. Cheers!!

Your feedbacks are always welcome. Feel free to drop your suggestions in the comment section. Thanks for reading, see you in the next one. Cheers!!

Originally published at https://dashprism.com on September 19, 2020.

--

--