Skip to content

Commit

Permalink
Remove more traces of cppsort::sort (issue #167)
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Morwenn committed Sep 23, 2020
1 parent 60455f2 commit 109461a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ should be trivial enough:
```cpp
#include <array>
#include <iostream>
#include <cpp-sort/sort.h>
#include <cpp-sort/sorters/smooth_sorter.h>

int main()
{
std::array<int, 5u> arr = { 5, 8, 3, 2, 9 };
cppsort::sort(arr);
std::array<int, 5> arr = { 5, 8, 3, 2, 9 };
cppsort::smooth_sort(arr);

// prints 2 3 5 8 9
for (int val: arr) {
std::cout << val << ' ';
Expand Down Expand Up @@ -63,15 +63,14 @@ int main()

// When used, this sorter will use a pattern-defeating quicksort
// to sort random-access collections, and a mergesort otherwise
using sorter = cppsort::hybrid_adapter<
cppsort::hybrid_adapter<
cppsort::pdq_sorter,
cppsort::merge_sorter
>;
sorter sort;
> sorter;

// Sort li and vec in reverse order using their value member
sort(li, std::greater<>{}, &wrapper::value);
sort(vec, std::greater<>{}, &wrapper::value);
sorter(li, std::greater<>{}, &wrapper::value);
sorter(vec, std::greater<>{}, &wrapper::value);

assert(std::equal(
std::begin(li), std::end(li),
Expand Down
11 changes: 5 additions & 6 deletions test_package/cpp-sort-integrity.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/*
* Copyright (c) 2018 Morwenn
* Copyright (c) 2018-2020 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <iterator>
#include <cpp-sort/sort.h>
#include <cpp-sort/sorters/smooth_sorter.h>

int main()
{
std::array<int, 5u> arr = { 5, 8, 3, 2, 9 };
cppsort::sort(arr);
assert(std::is_sorted(std::begin(arr), std::end(arr)));
std::array<int, 5> arr = { 5, 8, 3, 2, 9 };
cppsort::smooth_sort(arr);
assert(std::is_sorted(arr.begin(), arr.end()));

// prints 2 3 5 8 9
for (int val: arr) {
Expand Down

0 comments on commit 109461a

Please sign in to comment.