Skip to content

Commit ee39da0

Browse files
committed
weak pointer added
1 parent 5194ad4 commit ee39da0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

CPP/Modern-cpp.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
[awesome cpp](https://github.com/rigtorp/awesome-modern-cpp)<br>
22
[Modern c++](https://www.modernescpp.com/index.php/table-of-content/)
3+
4+
- Memory Model
5+
1. Overview
6+
2. Atomic data types
7+
1. std::atomic_flag
8+
2. std::atomic
9+
3. std::atomic
10+
3. Synchronization and ordering constraints
11+
4. Diff C++ memory model
12+
1. Sequential consistency
13+
2. Acquire-release semantic
14+
5. Fences
15+
6. Algorithms
16+
- Threading interface
17+
1. Threads
18+
2. Thread local data
19+
3. Condition Variable
20+
4. Tasks
21+
- Multithreading with C++17 and C++20
22+
1. Parallel Algorithms of STL
23+
2. Atomic Smart Pointers
24+
3. std::future extensions
25+
4. Latches and Barriers
26+
5. Coroutines
27+
6. Transactional Memory
28+
7. Task Blocks
29+
8. Executors
30+
9. Unified Future
31+
10. std::jthread
32+
- Application of Multithreading

DSA/Graph/GraphInput.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include<queue>
4+
using namespace std;
5+
6+
void BFSRecursive(const vector<vector<pair<int, int>>> &graph, queue<int> &q,
7+
vector<bool> &discovered) {
8+
if (q.empty())
9+
return;
10+
int v = q.front();
11+
q.pop();
12+
cout << v << " ";
13+
for(auto u : graph[v]) {
14+
if (!discovered[u.first])
15+
discovered[u.first] = true;
16+
q.push(u.first);
17+
}
18+
BFSRecursive(graph, q, discovered);
19+
}
20+
int main()
21+
{
22+
int n, m;
23+
cin >> n >> m;
24+
vector<vector<pair<int, int> > > graph(n, vector<pair<int, int> >(m));
25+
// undirected graph
26+
for (int i = 0; i < m; i++)
27+
{
28+
int u, v, w;
29+
cin >> u >> v >> w;
30+
graph[u].push_back(make_pair(v, w));
31+
graph[v].push_back(make_pair(u, w));
32+
}
33+
// directed graph
34+
for (int i = 0; i < m; i++)
35+
{
36+
int u, v, w;
37+
cin >> u >> v >> w;
38+
graph[u].push_back(make_pair(v, w));
39+
}
40+
queue<int> q;
41+
vector<bool> discovered;
42+
BFSRecursive(graph, q, discovered);
43+
}

0 commit comments

Comments
 (0)