📘 Lesson · Lesson 74
STL Overview
STL Overview
What is the STL?
💡 Note
The STL (Standard Template Library) provides ready-made containers (vector, map, set), algorithms (sort, find) and iterators.
Main Parts
- Containers — vector, list, map, set, stack, queue.
- Algorithms — sort, find, count, reverse.
- Iterators — move through containers.
Example
C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v = {5, 2, 8, 1};
sort(v.begin(), v.end()); // STL algorithm
for (int x : v) cout << x << " "; // 1 2 5 8
return 0;
}Output:
1 2 5 8
1 2 5 8
Summary
- STL = containers + algorithms + iterators, ready to use.
- Saves time vs writing data structures from scratch.
STL क्या है?
💡 Note
STL (Standard Template Library) ready-made containers (vector, map, set), algorithms (sort, find) और iterators देती है।
मुख्य भाग
- Containers — vector, list, map, set, stack, queue।
- Algorithms — sort, find, count, reverse।
- Iterators — containers में घूमते हैं।
Example
C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v = {5, 2, 8, 1};
sort(v.begin(), v.end()); // STL algorithm
for (int x : v) cout << x << " "; // 1 2 5 8
return 0;
}Output:
1 2 5 8
1 2 5 8
सारांश
- STL = containers + algorithms + iterators, ready to use।
- Data structures खुद लिखने से समय बचाता है।