tasks 01-06 - #18
Conversation
| }; | ||
|
|
||
| Graph::Graph(int vertices) { | ||
| V = vertices; |
There was a problem hiding this comment.
warning: 'V' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_02/src/main.cpp:18:
- Graph::Graph(int vertices) {
- V = vertices;
+ Graph::Graph(int vertices) : V(vertices) {
+ |
|
||
| Graph::Graph(int vertices) { | ||
| V = vertices; | ||
| adj = new std::list<int>[V]; |
There was a problem hiding this comment.
warning: 'adj' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_02/src/main.cpp:18:
- Graph::Graph(int vertices) {
+ Graph::Graph(int vertices), adj(new std::list<int>[V]) {| adj = new std::list<int>[V]; | |
| visited[u] = true; | ||
| disc[u] = low[u] = ++time; | ||
|
|
||
| for (int v : adj[u]) { |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| for (int v : adj[u]) { | |
| for (int const v : adj[u]) { |
| visited[u] = true; | ||
| disc[u] = low[u] = ++time; | ||
|
|
||
| for (int v : adj[u]) { |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| for (int v : adj[u]) { | |
| for (int const v : adj[u]) { |
| std::vector<std::pair<int, int>> *edges; | ||
|
|
||
| Graph(int vertices) { | ||
| numVertices = vertices; |
There was a problem hiding this comment.
warning: 'numVertices' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_03/src/main.cpp:13:
- Graph(int vertices) {
- numVertices = vertices;
+ Graph(int vertices) : numVertices(vertices) {
+ | void relax(int start, int current, std::vector<std::vector<int>>& distances, std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>>& q) { | ||
| for (const auto& edge : adjacencyList[current]) { | ||
| int next = edge.first; | ||
| int weight = edge.second; |
There was a problem hiding this comment.
warning: variable 'weight' of type 'int' can be declared 'const' [misc-const-correctness]
| int weight = edge.second; | |
| int const weight = edge.second; |
| q.emplace(0, start); | ||
|
|
||
| while (!q.empty()) { | ||
| int current = q.top().second; |
There was a problem hiding this comment.
warning: variable 'current' of type 'int' can be declared 'const' [misc-const-correctness]
| int current = q.top().second; | |
| int const current = q.top().second; |
| }; | ||
|
|
||
| int main() { | ||
| int vertices = 5; |
There was a problem hiding this comment.
warning: variable 'vertices' of type 'int' can be declared 'const' [misc-const-correctness]
| int vertices = 5; | |
| int const vertices = 5; |
| }; | ||
|
|
||
| SegmentTree::SegmentTree(const vector<int>& array) { | ||
| arr = array; |
There was a problem hiding this comment.
warning: 'arr' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_05/src/main.cpp:20:
- SegmentTree::SegmentTree(const vector<int>& array) {
- arr = array;
+ SegmentTree::SegmentTree(const vector<int>& array) : arr(array) {
+ | SegmentTree::SegmentTree(const vector<int>& array) { | ||
| arr = array; | ||
| tree.resize(4 * arr.size()); | ||
| build(1, 0, arr.size() - 1); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
build(1, 0, arr.size() - 1);
^
No description provided.