Tasks - #8
Conversation
| { | ||
| if(colors[i] == 0) | ||
| { | ||
| still_white = i; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
still_white = i;
^|
|
||
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; |
There was a problem hiding this comment.
warning: 'graph_list' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_01/src/topology_sort.cpp:63:
- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph) : graph_list(new_graph)| graph_list = new_graph; | |
|
|
||
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; |
There was a problem hiding this comment.
warning: parameter 'new_graph' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
graph_list = new_graph;
^this fix will not be applied because it overlaps with another fix
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| { | ||
| graph_list = new_graph; | ||
| timer = 0; |
There was a problem hiding this comment.
warning: 'timer' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
task_01/src/topology_sort.cpp:63:
- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph), timer(0)| timer = 0; | |
| } | ||
|
|
||
| std::set<std::pair<int, int>> findBridges (const std::vector<std::vector<int>>& graph){ | ||
| int time = 0; |
There was a problem hiding this comment.
warning: variable 'time' of type 'int' can be declared 'const' [misc-const-correctness]
| int time = 0; | |
| int const time = 0; |
| size_t pow_len = std::pow(2, pow); | ||
| minimum_table.push_back(input_vector); | ||
| minimum_table[0].resize(pow_len, __INT_MAX__); | ||
| int current_pow = pow - 1; |
There was a problem hiding this comment.
warning: Value stored to 'current_pow' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
int current_pow = pow - 1;
^Additional context
task_05/src/RMQ.cpp:9: Value stored to 'current_pow' during its initialization is never read
int current_pow = pow - 1;
^| size_t pow_len = std::pow(2, pow); | ||
| minimum_table.push_back(input_vector); | ||
| minimum_table[0].resize(pow_len, __INT_MAX__); | ||
| int current_pow = pow - 1; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
int current_pow = pow - 1;
^| int RMQ::findMin(const unsigned int left, const unsigned int right){ | ||
| if(left > right || left < 0 || right > minimum_table[0].size()) | ||
| throw std::out_of_range ("wrong border arguments"); | ||
| size_t row = std::floor(std::log2(right - left + 1)); |
There was a problem hiding this comment.
warning: variable 'row' of type 'size_t' (aka 'unsigned long') can be declared 'const' [misc-const-correctness]
| size_t row = std::floor(std::log2(right - left + 1)); | |
| size_t const row = std::floor(std::log2(right - left + 1)); |
| if(left > right || left < 0 || right > minimum_table[0].size()) | ||
| throw std::out_of_range ("wrong border arguments"); | ||
| size_t row = std::floor(std::log2(right - left + 1)); | ||
| return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]); |
There was a problem hiding this comment.
warning: narrowing conversion from 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]);
^| @@ -1,6 +1,72 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| std::vector<int> d(static_cast<size_t> (graph.size())); | ||
|
|
||
| if(fordBellman(graph.size(), graph, d) == 0){ | ||
| throw std::runtime_error("negative cycle"); |
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]
st<size_t> (graph.size()));
^| } | ||
|
|
||
| Graph::Graph(std::vector<std::vector<int>> new_graph) | ||
| : graph_list(new_graph), timer(0) { |
There was a problem hiding this comment.
warning: parameter 'new_graph' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
task_01/src/topology_sort.cpp:1:
+
+ #include <utility>| : graph_list(new_graph), timer(0) { | |
| : graph_list(std::move(new_graph)), timer(0) { |
| std::vector<int> d(static_cast<size_t>(graph.size())); | ||
|
|
||
| if (fordBellman(graph.size(), graph, d) == 0) { | ||
| throw std::runtime_error("negative cycle"); |
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]
ast<size_t>(graph.size()));
^| #include "Dijkstra.hpp" | ||
|
|
||
| int main() { | ||
| std::vector<std::vector<Vertex>> graph = { |
There was a problem hiding this comment.
warning: variable 'graph' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]
| std::vector<std::vector<Vertex>> graph = { | |
| std::vector<std::vector<Vertex>> const graph = { |
| #include "LCA.hpp" | ||
|
|
||
|
|
||
| Node::Node(int val) : value(val), height(0), used(false) {} |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: left_child, right_child [cppcoreguidelines-pro-type-member-init]
task_06/src/LCA.hpp:9:
- Node *left_child;
- Node *right_child;
+ Node *left_child{};
+ Node *right_child{};| values.push_back(current_vertex->value); | ||
| current_vertex->height = current_height; | ||
| current_vertex->used = true; | ||
| indexes[current_vertex->value] = values.size(); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'mapped_type' (aka 'int') is implementation-defined [cppcoreguidelines-narrowing-conversions]
indexes[current_vertex->value] = values.size();
^| } | ||
|
|
||
| int BinaryTree::findMin(int value1, int value2) { | ||
| int left = std::min(indexes[value1], indexes[value2]); |
There was a problem hiding this comment.
warning: variable 'left' of type 'int' can be declared 'const' [misc-const-correctness]
| int left = std::min(indexes[value1], indexes[value2]); | |
| int const left = std::min(indexes[value1], indexes[value2]); |
|
|
||
| int BinaryTree::findMin(int value1, int value2) { | ||
| int left = std::min(indexes[value1], indexes[value2]); | ||
| int right = std::max(indexes[value1], indexes[value2]); |
There was a problem hiding this comment.
warning: variable 'right' of type 'int' can be declared 'const' [misc-const-correctness]
| int right = std::max(indexes[value1], indexes[value2]); | |
| int const right = std::max(indexes[value1], indexes[value2]); |
| const size_t pow_len = static_cast<size_t>(std::pow(2, pow)); | ||
| std::vector<TableElement> first_row; | ||
| for (size_t i = 0; i < input_vector.size(); ++i) { | ||
| first_row.push_back(TableElement(input_vector[i], i)); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
first_row.push_back(TableElement(input_vector[i], i));
^| first_row.push_back(TableElement(input_vector[i], i)); | ||
| } | ||
| for (size_t i = input_vector.size(); i < pow_len; ++i) { | ||
| first_row.push_back(TableElement(__INT_MAX__, i)); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
first_row.push_back(TableElement(__INT_MAX__, i));
^| @@ -0,0 +1,62 @@ | |||
| #include "LCA.hpp" | |||
|
|
|||
| #include "../../task_05/src/RMQ.cpp" | |||
There was a problem hiding this comment.
warning: suspicious #include of file with '.cpp' extension [bugprone-suspicious-include]
#include "../../task_05/src/RMQ.cpp"
^Additional context
task_06/src/LCA.cpp:2: did you mean to include '../../task_05/src/RMQ.hpp'?
#include "../../task_05/src/RMQ.cpp"
^| @@ -1,6 +1,146 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| std::vector<int> d(static_cast<int>(graph.size())); | ||
|
|
||
| if (fordBellman(graph.size(), graph, d) == 0) { | ||
| throw std::runtime_error("negative cycle"); |
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]
c_cast<int>(graph.size()));
^| #include "prim.hpp" | ||
|
|
||
| int main() { | ||
| std::vector<std::vector<Vertex>> graph{ |
There was a problem hiding this comment.
warning: variable 'graph' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]
| std::vector<std::vector<Vertex>> graph{ | |
| std::vector<std::vector<Vertex>> const graph{ |
| {{3, 2}, {0, 7}, {5, 3}}, | ||
| {{4, 3}, {0, 10}, {6, 4}}, | ||
| {{0, 1}, {5, 4}}}; | ||
| std::vector<std::vector<Vertex>> tree = prim(graph); |
There was a problem hiding this comment.
warning: variable 'tree' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]
| std::vector<std::vector<Vertex>> tree = prim(graph); | |
| std::vector<std::vector<Vertex>> const tree = prim(graph); |
| if (!colors[graph[i][j].destination]) { | ||
| if (min > graph[i][j].weight) { | ||
| min = graph[i][j].weight; | ||
| x = i; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
x = i;
^| if (min > graph[i][j].weight) { | ||
| min = graph[i][j].weight; | ||
| x = i; | ||
| y = j; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
y = j;
^
No description provided.