Skip to content

Conversation

@18thday
Copy link
Contributor

@18thday 18thday commented Dec 24, 2025

No description provided.

rhs.birth_date.year,
rhs.birth_date.month,
rhs.birth_date.day);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Тут несколько проблем:

  1. Кортеж таким образом не очень эффективно делать, поскольку создадуться копии, лучше использовать std::tie который использует ссылки
  2. Лучше написать отдельный оператор для даты и в данном случае использовать не каждое поле а сразу сравнение класса даты, поскольку там нет особенностей в поведении
  3. Действия с оценкой и курсом излишни, поскольку можно просто в левый операнд отправиль rhs.field, а в правый lhs.field в нужных местах

}
os << "DEST";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Дублирования конечно хотелось бы избежать

for (size_t readIndex = 0; readIndex < array.size(); ++readIndex) {
if (predicate(array[readIndex])) {
if (writeIndex != readIndex) {
array[writeIndex] = std::move(array[readIndex]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

использование std::move не очень корректно, так как работа с фундаментальным типом, скопировать будет лучше

//Итераторы ведут себя примерно также как указатели, но они могут быть и не указателями, а хоть чем. Это абстракция некая над указателем, если можно так сказать
*/

using IteratorsPairReturn = std::pair<std::vector<int>::const_iterator,std::vector<int>::const_iterator> ;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • лишний пробел в конце, и можно было ограничится псевдонимом для итератора, так как он дублируется
  • не хватает пробела после запятой

}
else if (*iter >= *maxIt) {
maxIt = iter;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

проблемы с выравниванием кода

os << "+";
} else {
os << "-";
}
Copy link
Contributor Author

@18thday 18thday Dec 24, 2025

Choose a reason for hiding this comment

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

в данном случае конечно используется тернарный оператор

for (int i = from; i > to; i += step) {
rangedArray.push_back(i);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

дублирование кода

}
else if (step < 0 && from > to) {
countSteps = (from - to - step - 1) / (-step);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

можно переписать с тернарным оператором при оъявлении

outputArray.push_back(inputArray[i]);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

не уверен в выгодности двух проходов


size_t uniqueCount = 1;
for (size_t i = 1; i < size; ++i) {
if (inputArray[i] != inputArray[i-1]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

не хватает пробелов вокруг оператора -

Copy link
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.

@Dsv9toy Данил, проверил первые 3 недели

  • неплохой код, но местами много дублирования
  • много ошибок по стилю кода, небрежность в выравнивании

bool operator!=(const Stack& otherStack) const;


private:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

std::vector<int> buffer_;
size_t oldestElement_ = 0;
size_t indexNextElem_ = 0;
size_t currentCountElem_ = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

несколько громоздкие названия, данное можно заменить на size_

buffer_.resize(capacity);
oldestElement_ = 0;
indexNextElem_ = 0;
currentCountElem_ = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

это должно быть все в списке инициализации

buffer_[0] = initialValue;
indexNextElem_ = 1 % buffer_.capacity();
currentCountElem_ = 1;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

это плохо, можно было в списке инициализации вызвать соответствуеющийконструктор вектора, а тут достаточно объемный код, но дае еслитак, лучшеизбавится от else и лишней вложенности и поставить внтруи if return

oldestElement_ = 0;
indexNextElem_ = 0;
currentCountElem_ = 0;
for (int value : init) Push(value); //Добавил range based, так как будто бы уютнее смотрится
Copy link
Contributor Author

Choose a reason for hiding this comment

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

аналогично, можно вызвать конструктор вектора от init

indexNextElem_ = NextIndex(indexNextElem_);
} else {
buffer_[indexNextElem_] = value;
indexNextElem_ = NextIndex(indexNextElem_);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

в каждой из ветвей есть общий код, дублирование

for (size_t i = 0; i < otherQueue.inputDat.size(); ++i) {
temp2.push_back(otherQueue.inputDat[i]);
}
return temp1 == temp2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

tempOutput.push_back(tempInput.back());
tempInput.pop_back();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

неэффективный метод с копированием

return outputDat.back();
}

const int& Queue::Front() const {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

методы Front неконсистенты между собой, используют разные подходы

Queue::Queue(std::initializer_list<int> initList) : inputDat(initList) {}

Queue::Queue(const std::stack<int>& stack) {
std::stack<int> temp = stack;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

std::stack<int> temp = stack;
// Извлекаем элементы из стека в обратном порядке
while (!temp.empty()) {
inputDat.insert(inputDat.begin(), temp.top());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

производить вставку в начало вектора очень неэффективно, когда есть контейнер output

}

Phasor operator/(const Phasor& phasor, double scalar) {
Phasor result = phasor;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

может тогда Phasor принимать как копию?

Copy link
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.

@Dsv9toy отметил следующие моменты, требующие исправления:

  • использование тела конструктора вместо списка инициализации
  • неэффективно сравнение в Queue с копированием
  • неэффектривный метод Front с копированием в 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.

3 participants