Hi Everyone ✋
In this tutorial series we will talk about C++ STL in depth.
STL stands for Standard Template Library.
STL has four components
Containers
Iterators
Algorithms
Function Objects
Containers
Containers are actually pre implemented data structures provided by C++ to use. These containers help us to write code efficiently without worrying about data structure implementation explicitly.
Containtainers can be divided in two parts mainly
-
-
-
-
- Sequential Containers
- Non-Sequential Containers
-
-
-
Sequential Containers
Sequential containers grow sequentially.
-
-
-
-
- Vector
- List
- Array
- Deque
- Forward List
- Stack
- Queue
- Priority Queue
-
-
-
Non-Sequential containers
Non-Sequential containers grow arbitrarily.
Non-Sequential containers can be divided into two parts also
-
-
-
-
- Associative Containers
- Unordered Associative Containers
-
-
-
Associative containers
Associative containers are sorted collections of data. Each element of an associative container is inserted in a sorted manner. Associative containers are –
-
-
-
-
- Set
- Multiset
- Map
- Multimap
-
-
-
Unordered associative containers
Unordered associative containers are unsorted collections of data. But unordered associative containers provide random access to each element which is really effective. Unordered associative containers are –
-
-
-
-
- Unordered_set
- Unorodered_multiset
- Unordered_map
- Unordered_multimap
-
-
-
Iterators
Iterators are mainly pointers of STL containers. Iterators are used to access the memory locations of STL containers. With the help of the iterator we can traverse any STL container easily. Iterators can be incremented and decremented.
it++, Incremented, After incremented it points to the next element in the current container
it−−, Decremented, After decrementing it points to the previous element in the current container
Algorithms
Algorithms in C++ are specially designed to be used on ranges of elements. Algorithms in C++ are a collection of functions which can be easily used by including <algorithm> header. Some of the algorithms are –
-
-
-
-
-
- Sort
- Merge
- Min
- Max
- Swap
- Replace
- Compare
-
-
-
-
And much more
Function Object
A function object is also known as a functor. A functor is any type that implements operator(). C++ STL mainly uses functors as sorting criteria for containers. Example –
struct Functor
{
bool operator()(int a, int b)
{
return a < b;
}
};
In the later tutorials, we will talk about every single of them in depth.
First we will start with containers, more specifically sequential containers and we will work our way up to STL algorithms.
🔑 Prerequisite skills for this tutorial series
-
-
-
-
-
- C++
- Data Structure
- Basic Understanding of Object Oriented Programming
-
-
-
-
In the next tutorial we will talk about Vector which is a sequential container.
Until then
Happy Coding 💻 🎵
Nice
What’s up mates, its enormous article concerning teachingand fully explained,
keep it up all the time.
Keep up the good work!
I need to to thank you for this good read!! I certainly loved every bit of it. I have you bookmarked to check out new stuff you postÖ