Skip to content

Мирошниченко Евгений#22

Open
18thday wants to merge 70 commits intopsds-cpp:mainfrom
EugeniusMiroshnichenko:main
Open

Мирошниченко Евгений#22
18thday wants to merge 70 commits intopsds-cpp:mainfrom
EugeniusMiroshnichenko:main

Conversation

@18thday
Copy link
Copy Markdown
Contributor

@18thday 18thday commented Dec 25, 2025

No description provided.

in_.reserve(size);
}
Queue(std::vector<int> vector){
in_ = vector;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

в списке инийиализации

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Да, так проще
0ad4174

stack.pop();
}

std::reverse(temp.begin(), temp.end());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

почему сразу не складывать в out_? без лишних копирований

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Согласен, так проще
0ad4174

in_.reserve(initList.size());
for (int val : initList) {
in_.push_back(val);
}
Copy link
Copy Markdown
Contributor Author

@18thday 18thday Jan 21, 2026

Choose a reason for hiding this comment

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

у вектора есть конструктор от класса список инициализации

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Реально
0ad4174

else {
// Если есть нет, то с конца последнего
return out_.front();
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

тернарный оператор, комментарии лишние

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Упростил
0ad4174

in_.clear();
out_.clear();
in_.shrink_to_fit();
out_.shrink_to_fit();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

shrink_to_fit() - не принято делать, clear обычно не освобождает память

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Согласен, size и без этого будет 0
0ad4174

void Swap(Queue& other){
std::swap(in_, other.in_);
std::swap(out_, other.out_);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

лишняя пустая строка

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

return false;
}
Queue one = *this;
Queue two = other;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

это слишком неэффективно, устройство очереди известно, поэтому в данном случае копирование слишком дорого, его можно избежатьсравнив элементы

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Для сравнения надо оба списка привести в один порядок, так как в одном списке часть элементов может быть в out_, а в другом в in_. Так как == должно работать в том числе с константными объектами, просто вызвать для них in_to_out не получается.
Сходу не вижу решения, как без создания нового списка с правильным порядком сравнить 2 таких структуры

}

bool operator!=(const Queue& other) const{
return ! (*this == other);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

лишний пробел

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Согласен
0ad4174


protected:
std:: vector <int> in_{};
std:: vector <int> out_{};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

это очень плохо, много лишних пробелов

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Исправил
0ad4174

return ! (*this == other);
}

protected:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

зачем модификатор protected?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Какое-то legacy
0ad4174

std:: vector <int> in_{};
std:: vector <int> out_{};

void In_to_out(){
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Разный стиль именования методов

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Не понял, о чем речь
Все мои методы snake_case с большой буквы


out_.swap(new_out);
in_.clear();
in_.shrink_to_fit();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

зачем его обрезать?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Согласен, size и без этого будет 0
0ad4174

}

Phasor(double ampl, double angle, ExpTag tag){
(void)tag;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

в С++ лучше [[maybe_unused]] в аргументах перед ExpTag tag, либо static_cast(tag)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Да, забыл что с-style лучше не использовать
0ad4174


Phasor& operator*=(Phasor& lhs, const Phasor& rhs) {
lhs.SetCartesian(lhs.Real() * rhs.Real() - lhs.Imag() * rhs.Imag(),
lhs.Real() * rhs.Imag() + lhs.Imag() * rhs.Real());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

выравнивание похало

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Согласен
0ad4174

Copy link
Copy Markdown
Contributor Author

@18thday 18thday left a comment

Choose a reason for hiding this comment

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

@EugeniusMiroshnichenko по задачам на классы:

  • использование тело конструктора вместо списка инициализации
  • использование this->
  • неэффективно сравнение в Queue с копированием
  • неэффективный конструктор от стека в Queue
  • поправить стиль кода

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.

2 participants