Skip to content

algoritmhms_2nd - #17

Open
MrSnoki wants to merge 3 commits into
DafeMipt213:mainfrom
MrSnoki:main
Open

algoritmhms_2nd#17
MrSnoki wants to merge 3 commits into
DafeMipt213:mainfrom
MrSnoki:main

Conversation

@MrSnoki

@MrSnoki MrSnoki commented Jan 11, 2024

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 29. Check the log or trigger a new build to see more.

Comment thread task_01/src/test.cpp
@@ -1,8 +1,38 @@

#include <gtest/gtest.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]

#include <gtest/gtest.h>
         ^

std::vector<int> Graph::topologicalSort() {
std::vector<int> inDegree(vertices, 0);
for (int u = 0; u < vertices; ++u) {
for (int v : adjList[u]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
for (int v : adjList[u]) {
for (int const v : adjList[u]) {


std::vector<int> result;
while (!q.empty()) {
int u = q.front();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'u' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int u = q.front();
int const u = q.front();

q.pop();
result.push_back(u);

for (int v : adjList[u]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
for (int v : adjList[u]) {
for (int const v : adjList[u]) {

Comment thread task_03/src/johnson.cpp
const int INF = std::numeric_limits<int>::max();

JohnsonAlgorithm::JohnsonAlgorithm(const std::vector<std::vector<int>>& g)
: graph(g), numVertices(g.size()) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

    : graph(g), numVertices(g.size()) {}
                            ^

Comment thread task_06/src/lca.cpp
#include <cmath>

Solution::Solution(std::vector<std::vector<int>> &data, int root) {
int size = data.size();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'size' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int size = data.size();
int const size = data.size();

Comment thread task_06/src/lca.cpp
#include <cmath>

Solution::Solution(std::vector<std::vector<int>> &data, int root) {
int size = data.size();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

    int size = data.size();
               ^

Comment thread task_06/src/lca.cpp
int size = data.size();
eulerian_tour_position_.assign(size, -1);
heights_.assign(size, 0);
eulerian_tour_.reserve(2 * size);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: performing an implicit widening conversion to type 'size_type' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]

    eulerian_tour_.reserve(2 * size);
                           ^
Additional context

task_06/src/lca.cpp:7: make conversion explicit to silence this warning

    eulerian_tour_.reserve(2 * size);
                           ^

task_06/src/lca.cpp:7: perform multiplication in a wider type

    eulerian_tour_.reserve(2 * size);
                           ^

Comment thread task_06/src/lca.cpp
heights_.assign(size, 0);
eulerian_tour_.reserve(2 * size);

adjacency_list_ = data;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'adjacency_list_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

task_06/src/lca.cpp:3:

- Solution::Solution(std::vector<std::vector<int>> &data, int root) {
+ Solution::Solution(std::vector<std::vector<int>> &data, int root) : adjacency_list_(data) {
Suggested change
adjacency_list_ = data;

Comment thread task_06/src/lca.cpp

adjacency_list_ = data;

parent_.assign(size, std::vector<int>(log2(size) + 1, -1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'double' to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]

    parent_.assign(size, std::vector<int>(log2(size) + 1, -1));
                                          ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant