From c4a5870aaa584cb32dffece10f0dabfb0ce5ea25 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 24 Oct 2021 12:12:01 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for 79341db8 --- sorting/selection_sort_iterative.cpp | 37 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sorting/selection_sort_iterative.cpp b/sorting/selection_sort_iterative.cpp index 51a8c27a9..79beed3fe 100644 --- a/sorting/selection_sort_iterative.cpp +++ b/sorting/selection_sort_iterative.cpp @@ -44,27 +44,28 @@ namespace sorting { * @returns @param array resultant sorted vector *******************************************************************************/ - std::vector selectionSort(const std::vector &arr, uint64_t len) { - - std::vector array(arr.begin(), arr.end()); //declare a vector in which result will be stored - for (uint64_t it = 0; it < len; ++it) { - - uint64_t min = it; // set min value - for (uint64_t it2 = it + 1; it2 < len; ++it2) { - if (array[it2] < array[min]) { // check which element is smaller - min = it2; // store index of smallest element to min - } - } - - if (min != it) { // swap if min does not match to i - uint64_t tmp = array[min]; - array[min] = array[it]; - array[it] = tmp; +std::vector selectionSort(const std::vector &arr, + uint64_t len) { + std::vector array( + arr.begin(), + arr.end()); // declare a vector in which result will be stored + for (uint64_t it = 0; it < len; ++it) { + uint64_t min = it; // set min value + for (uint64_t it2 = it + 1; it2 < len; ++it2) { + if (array[it2] < array[min]) { // check which element is smaller + min = it2; // store index of smallest element to min } } - return array; //return sorted vector + if (min != it) { // swap if min does not match to i + uint64_t tmp = array[min]; + array[min] = array[it]; + array[it] = tmp; + } } + + return array; // return sorted vector +} } // namespace sorting /******************************************************************************* @@ -90,7 +91,7 @@ static void test() { std::cout << "2nd test... "; std::vector result_test2; result_test2 = sorting::selectionSort(vector2, vector2size); - assert(std::is_sorted(result_test2.begin(),result_test2.end())); + assert(std::is_sorted(result_test2.begin(), result_test2.end())); std::cout << "Passed" << std::endl; // testcase #3