Skip to content

YuriyKuznetsov_HomeWork4#38

Open
GKuzzinshtern wants to merge 2 commits intomainfrom
YuriyKuznetsov_HomeWork4
Open

YuriyKuznetsov_HomeWork4#38
GKuzzinshtern wants to merge 2 commits intomainfrom
YuriyKuznetsov_HomeWork4

Conversation

@GKuzzinshtern
Copy link
Collaborator

No description provided.

The fastest is STL sort() :) The next is "quicksort". And the slowest is "bubble sort", though I like it for it's simplicity :)
for (uint32_t *uiTrying = uiBegin; uiTrying != uiEnd; ++uiTrying) {
bool bChanged = false;
for (uint32_t *uiElem = uiBegin; uiElem != (uiEnd - 1); ++uiElem) {
if (predicat(*uiElem, *(uiElem + 1))) {
Copy link
Owner

Choose a reason for hiding this comment

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

странное поведение когда предикат дает true и мы делаем continue, чаще все наоборот

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

я в лямбду отправляю критерий a < b при сортировке по возрастанию, это наглядно. Соответственно тут, если условие выполняется, то не нужно переставлять. Возможно, я смотрю как-то субъективно?

}

bool bFillingManual(YuArray &in_out_Array) {
for (size_t sizeIndex = 0; sizeIndex != sizeARRAY; ++sizeIndex) {
Copy link
Owner

Choose a reason for hiding this comment

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

вместо sizeARRAY лучше in_out_Array.size()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Да, вот с этим, кстати, вопрос. in_out_Array.size() наверняка возьмет размер из переменной, а не будет обсчитывать массив. Тогда да, так будет лучше.

bool bFillingManual(YuArray &in_out_Array) {
for (size_t sizeIndex = 0; sizeIndex != sizeARRAY; ++sizeIndex) {
std::cout << "Enter integer value for [" << sizeIndex << "] array member: ";
if (!(std::cin >> in_out_Array.at(sizeIndex))) { // skip other checkings
Copy link
Owner

Choose a reason for hiding this comment

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

какой смысл тут at?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Он мне в принципе нравится :) Что можно поймать его ексепшн. Хотя тут выход за пределы массива маловероятен.

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

Comments