Skip to content

Commit

Permalink
fix: Remove unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukli committed Oct 4, 2023
1 parent 45c1821 commit 70dd8f8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions include/forfun/sorting/insertion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

namespace forfun::sorting {

template <typename T, typename RandomIt>
template <typename RandomIt>
constexpr inline void
insertion_sort(T& container, RandomIt const begin, RandomIt const end) noexcept
insertion_sort(RandomIt const begin, RandomIt const end) noexcept
{
if (begin != end)
{
Expand Down
16 changes: 8 additions & 8 deletions include/forfun/sorting/quicksort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace forfun::sorting {

namespace {

template <typename T, typename RandomIt>
template <typename RandomIt>
[[nodiscard]] constexpr inline RandomIt
partition(T& container, RandomIt const lo, RandomIt const hi) noexcept
partition(RandomIt const lo, RandomIt const hi) noexcept
{
auto const pivot = *hi;

Expand All @@ -41,18 +41,18 @@ partition(T& container, RandomIt const lo, RandomIt const hi) noexcept

} // namespace

template <typename T, typename RandomIt>
constexpr inline void
quicksort(T& container, RandomIt const lo, RandomIt const hi) noexcept
template <typename RandomIt>
constexpr inline void quicksort(RandomIt const lo, RandomIt const hi) noexcept
{
if (hi > lo)
{
auto const p{partition(container, lo, hi)};
auto const p{partition(lo, hi)};

quicksort(container, lo, std::prev(p));
quicksort(container, std::next(p), hi);
quicksort(lo, std::prev(p));
quicksort(std::next(p), hi);
}
}

} // namespace forfun::sorting

#endif // FORFUN_SORTING_QUICKSORT_HPP_
20 changes: 10 additions & 10 deletions test/sorting/insertion_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::array<int, 0> test_input{};
static constexpr std::array<int, 0> const expected_output{};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 0);

Expand All @@ -30,7 +30,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::array test_input{7};
static constexpr std::array const expected_output{7};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 1);

Expand All @@ -41,7 +41,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::array test_input{1, 1};
static constexpr std::array const expected_output{1, 1};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 2);

Expand All @@ -52,7 +52,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::array test_input{-6, 3, 11};
static constexpr std::array const expected_output{-6, 3, 11};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 3);

Expand All @@ -64,7 +64,7 @@ TEST_CASE("Insertion sort", "[sorting]")
std::array test_input{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
static constexpr std::array const expected_output{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 10);

Expand All @@ -76,7 +76,7 @@ TEST_CASE("Insertion sort", "[sorting]")
std::array test_input{9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
static constexpr std::array const expected_output{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 10);

Expand All @@ -88,7 +88,7 @@ TEST_CASE("Insertion sort", "[sorting]")
std::array test_input{200, 4, 7, 0, 9, -10, 2};
static constexpr std::array const expected_output{
-10, 0, 2, 4, 7, 9, 200};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 7);

Expand All @@ -99,7 +99,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::vector test_input{8, 4, 7, 0, 9, 5, 2};
std::vector const expected_output{0, 2, 4, 5, 7, 8, 9};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

CHECK(test_input.size() == 7);

Expand All @@ -110,7 +110,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::vector test_input{8, 4, 7, 0, 9, 5, 2};
std::vector const expected_output{0, 2, 4, 5, 7, 8, 9};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

CHECK(test_input.size() == 7);

Expand All @@ -121,7 +121,7 @@ TEST_CASE("Insertion sort", "[sorting]")
{
std::vector test_input{-8, -4, -7, -4, -9, -5, -2};
std::vector const expected_output{-9, -8, -7, -5, -4, -4, -2};
insertion_sort(test_input, test_input.begin(), test_input.end());
insertion_sort(test_input.begin(), test_input.end());

CHECK(test_input.size() == 7);

Expand Down
20 changes: 10 additions & 10 deletions test/sorting/quicksort_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::array<int, 0> test_input{};
static constexpr std::array<int, 0> const expected_output{};
quicksort(test_input, test_input.begin(), test_input.end());
quicksort(test_input.begin(), test_input.end());

STATIC_CHECK(test_input.size() == 0);

Expand All @@ -30,7 +30,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::array test_input{7};
static constexpr std::array const expected_output{7};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 1);

Expand All @@ -41,7 +41,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::array test_input{1, 1};
static constexpr std::array const expected_output{1, 1};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 2);

Expand All @@ -52,7 +52,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::array test_input{-6, 3, 11};
static constexpr std::array const expected_output{-6, 3, 11};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 3);

Expand All @@ -64,7 +64,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
std::array test_input{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
static constexpr std::array const expected_output{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 10);

Expand All @@ -76,7 +76,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
std::array test_input{9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
static constexpr std::array const expected_output{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 10);

Expand All @@ -88,7 +88,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
std::array test_input{200, 4, 7, 0, 9, -10, 2};
static constexpr std::array const expected_output{
-10, 0, 2, 4, 7, 9, 200};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

STATIC_CHECK(test_input.size() == 7);

Expand All @@ -99,7 +99,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::vector test_input{8, 4, 7, 0, 9, 5, 2};
std::vector const expected_output{0, 2, 4, 5, 7, 8, 9};
quicksort(test_input, test_input.begin(), std::prev(test_input.end()));
quicksort(test_input.begin(), std::prev(test_input.end()));

CHECK(test_input.size() == 7);

Expand All @@ -110,7 +110,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::vector test_input{8, 4, 7, 0, 9, 5, 2};
std::vector const expected_output{0, 2, 4, 5, 7, 8, 9};
quicksort(test_input, test_input.begin(), test_input.end() - 1);
quicksort(test_input.begin(), test_input.end() - 1);

CHECK(test_input.size() == 7);

Expand All @@ -121,7 +121,7 @@ TEST_CASE("Quicksort sort", "[sorting]")
{
std::vector test_input{-8, -4, -7, -4, -9, -5, -2};
std::vector const expected_output{-9, -8, -7, -5, -4, -4, -2};
quicksort(test_input, test_input.begin(), test_input.end() - 1);
quicksort(test_input.begin(), test_input.end() - 1);

CHECK(test_input.size() == 7);

Expand Down

0 comments on commit 70dd8f8

Please sign in to comment.