diff --git a/libs/main/containers/pideque.h b/libs/main/containers/pideque.h index a0658d56..cc7e7a33 100644 --- a/libs/main/containers/pideque.h +++ b/libs/main/containers/pideque.h @@ -1494,11 +1494,11 @@ public: //! \~\details //! \~english The order of equal elements is not guaranteed to be preserved. //! Elements are compared using operator<. - //! Sorting provided by [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort). + //! Sorting provided by [std::stable_sort](https://en.cppreference.com/w/cpp/algorithm/stable_sort). //! Complexity `O(N·log(N))`. //! \~russian Сохранность порядка элементов, имеющих одинаковое значение, не гарантируется. //! Для сравнения элементов используется оператор `operator<`. - //! Для сортировки используется функция [std::sort](https://ru.cppreference.com/w/cpp/algorithm/sort). + //! Для сортировки используется функция [std::stable_sort](https://ru.cppreference.com/w/cpp/algorithm/stable_sort). //! Сложность сортировки `O(N·log(N))`. //! \~\code //! PIDeque v{5, 7, 4, 2, 8, 6, 1, 9, 0, 3}; @@ -1507,7 +1507,7 @@ public: //! \endcode //! \~\sa \a sort(std::function comp) inline PIDeque & sort() { - std::sort(begin(), end()); + std::stable_sort(begin(), end()); return *this; } @@ -1524,7 +1524,7 @@ public: //! While the signature does not need to have const &, the function must not modify the objects passed to it. //! The function must return `false` for identical elements, //! otherwise, it will lead to undefined program behavior and memory errors. - //! Sorting provided by [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort). + //! Sorting provided by [std::stable_sort](https://en.cppreference.com/w/cpp/algorithm/stable_sort). //! Complexity `O(N·log(N))`. //! \~russian Сохранность порядка элементов, имеющих одинаковое значение, не гарантируется. //! Для сравнения элементов используется функция сравнения `comp`. @@ -1532,7 +1532,7 @@ public: //! второго. Сигнатура функции сравнения должна быть эквивалентна следующей: \code bool comp(const T &a, const T &b); \endcode Сигнатура //! не обязана содержать const &, однако, функция не может изменять переданные объекты. Функция обязана возвращать `false` для //! одинаковых элементов, иначе это приведёт к неопределённому поведению программы и ошибкам памяти. Для сортировки используется функция - //! [std::sort](https://ru.cppreference.com/w/cpp/algorithm/sort). Сложность сортировки `O(N·log(N))`. + //! [std::stable_sort](https://ru.cppreference.com/w/cpp/algorithm/stable_sort). Сложность сортировки `O(N·log(N))`. //! \~\code //! PIDeque v{5, 7, 4, 2, 8, 6, 1, 9, 0, 3}; //! v.sort([](const int & a, const int & b){return a > b;}); @@ -1540,7 +1540,7 @@ public: //! \endcode //! \~\sa \a sort() inline PIDeque & sort(std::function comp) { - std::sort(begin(), end(), comp); + std::stable_sort(begin(), end(), comp); return *this; } diff --git a/libs/main/containers/pivector.h b/libs/main/containers/pivector.h index b6e501e9..59f0786d 100644 --- a/libs/main/containers/pivector.h +++ b/libs/main/containers/pivector.h @@ -1420,11 +1420,11 @@ public: //! \~\details //! \~english The order of equal elements is not guaranteed to be preserved. //! Elements are compared using operator<. - //! Sorting provided by [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort). + //! Sorting provided by [std::stable_sort](https://en.cppreference.com/w/cpp/algorithm/stable_sort). //! Complexity `O(N·log(N))`. //! \~russian Сохранность порядка элементов, имеющих одинаковое значение, не гарантируется. //! Для сравнения элементов используется оператор `operator<`. - //! Для сортировки используется функция [std::sort](https://ru.cppreference.com/w/cpp/algorithm/sort). + //! Для сортировки используется функция [std::stable_sort](https://ru.cppreference.com/w/cpp/algorithm/stable_sort). //! Сложность сортировки `O(N·log(N))`. //! \~\code //! PIVector v{5, 7, 4, 2, 8, 6, 1, 9, 0, 3}; @@ -1433,7 +1433,7 @@ public: //! \endcode //! \~\sa \a sort(std::function comp) inline PIVector & sort() { - std::sort(begin(), end()); + std::stable_sort(begin(), end()); return *this; } @@ -1450,7 +1450,7 @@ public: //! While the signature does not need to have const &, the function must not modify the objects passed to it. //! The function must return `false` for identical elements, //! otherwise, it will lead to undefined program behavior and memory errors. - //! Sorting provided by [std::sort](https://en.cppreference.com/w/cpp/algorithm/sort). + //! Sorting provided by [std::stable_sort](https://en.cppreference.com/w/cpp/algorithm/stable_sort). //! Complexity `O(N·log(N))`. //! \~russian Сохранность порядка элементов, имеющих одинаковое значение, не гарантируется. //! Для сравнения элементов используется функция сравнения `comp`. @@ -1458,7 +1458,7 @@ public: //! второго. Сигнатура функции сравнения должна быть эквивалентна следующей: \code bool comp(const T &a, const T &b); \endcode Сигнатура //! не обязана содержать const &, однако, функция не может изменять переданные объекты. Функция обязана возвращать `false` для //! одинаковых элементов, иначе это приведёт к неопределённому поведению программы и ошибкам памяти. Для сортировки используется функция - //! [std::sort](https://ru.cppreference.com/w/cpp/algorithm/sort). Сложность сортировки `O(N·log(N))`. + //! [std::stable_sort](https://ru.cppreference.com/w/cpp/algorithm/stable_sort). Сложность сортировки `O(N·log(N))`. //! \~\code //! PIVector v{5, 7, 4, 2, 8, 6, 1, 9, 0, 3}; //! v.sort([](const int & a, const int & b){return a > b;}); @@ -1466,7 +1466,7 @@ public: //! \endcode //! \~\sa \a sort() inline PIVector & sort(std::function comp) { - std::sort(begin(), end(), comp); + std::stable_sort(begin(), end(), comp); return *this; } diff --git a/libs/main/text/pistring.cpp b/libs/main/text/pistring.cpp index a389a998..b5521b0f 100644 --- a/libs/main/text/pistring.cpp +++ b/libs/main/text/pistring.cpp @@ -536,7 +536,7 @@ PIString PIString::minArgPlaceholder() { bool ok = false; tmp = mid(i + 1, j - i - 1); int cur = tmp.toInt(10, &ok); - if (!ok) continue; + if (!ok || tmp.isEmpty()) continue; if (min < 0 || min > cur) { min = cur; ret = tmp;