Introduction to STL: Containers, Algorithms, iterators – potential problems with STL| OOP in C++

Standard Template Library

The collection of genetic classes and functions is called Standard Template Library(STL).
Components of STL
(A) Containers
(B) Algorithms
(C) Iterators
Container is an object that actually stores data STL containers are implemented by template classes and therefore can be used with different data types. Example-Array(integer array, char array, float array)
ALGORITHM is a procedure that is used to process data present in container. Algorithms are implemented using template function.

The following tasks can be done using algorithms: Initialization, Searching, Sorting, Copying, Merging.etc.

Iterator is an object, like a pointer, that points to an element in a container one can increment/decrement iterators.
Iterator connects algorithm with containers
Type of Containers in STL
1. Sequence Container
2. Associative Container
3. Derived Container
-priority queue

stl containers
 Note:- Derived containers like stack, queue, priority queue do not support iterators, however they support two member functions, push() and pop().

Algorithms are not member function or friend function of any class. They are stand alone template functions.
Type of STL Algorithms
1. Retrieve or Non-mutating
2. Mutating
3. Sorting
4. Set
5. Relational

Custom Search

%d bloggers like this: