Skip to content

Commit 3f4044e

Browse files
authored
Merge pull request #197 from Morwenn/develop
Release 1.12.1
2 parents f081ed4 + ce9b49e commit 3f4044e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+944
-439
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.8.0)
55

66
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
77

8-
project(cpp-sort VERSION 1.12.0 LANGUAGES CXX)
8+
project(cpp-sort VERSION 1.12.1 LANGUAGES CXX)
99

1010
include(CMakePackageConfigHelpers)
1111
include(GNUInstallDirs)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![Latest Release](https://img.shields.io/badge/release-1.12.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.12.0)
2-
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.12.0-blue.svg)](https://conan.io/center/cpp-sort?version=1.12.0)
1+
[![Latest Release](https://img.shields.io/badge/release-1.12.1-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.12.1)
2+
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.12.1-blue.svg)](https://conan.io/center/cpp-sort?version=1.12.1)
33
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)
44

55
> *It would be nice if only one or two of the sorting methods would dominate all of the others,

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CppSortConan(ConanFile):
1212
name = "cpp-sort"
13-
version = "1.12.0"
13+
version = "1.12.1"
1414
description = "Additional sorting algorithms & related tools"
1515
topics = "conan", "cpp-sort", "sorting", "algorithms"
1616
url = "https://github.com/Morwenn/cpp-sort"

docs/Home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Welcome to the **cpp-sort 1.12.0** documentation!
1+
Welcome to the **cpp-sort 1.12.1** documentation!
22

33
You probably read the introduction in the README, so I won't repeat it here. This wiki contains documentation about the library: basic documentation about the many sorting tools and how to use them, documentation about the additional utilities provided by the library and even some detailed tutorials if you ever want to write your own sorters or sorter adapters. This main page explains a few general things that didn't quite fit in other parts of the documentation.
44

docs/Miscellaneous-utilities.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ using make_index_range = make_integer_range<std::size_t, Begin, End, Step>;
247247

248248
`size` is a function that can be used to get the size of an iterable. It is equivalent to the C++17 function [`std::size`][std-size] but has an additional tweak so that, if the iterable is not a fixed-size C array and doesn't have a `size` method, it calls `std::distance(std::begin(iter), std::end(iter))` on the iterable. Therefore, this function can also be used for `std::forward_list` as well as some implementations of ranges.
249249

250+
*Changed in version 1.12.1:* `utility::size()` now also works for collections that only provide non-`const` `begin()` and `end()`.
251+
250252
### Sorting network tools
251253

252254
```cpp

docs/Sorters.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ This sorter also has the following dedicated algorithms when used together with
309309

310310
None of the container-aware algorithms invalidates iterators.
311311

312-
### `slab_sort`
312+
### `slab_sorter`
313313

314314
```cpp
315315
#include <cpp-sort/sorters/slab_sorter.h>
@@ -319,12 +319,14 @@ Implements a variant of slabsort, a rather slow but highly adaptive algorithm de
319319

320320
| Best | Average | Worst | Memory | Stable | Iterators |
321321
| ----------- | ----------- | ----------- | ----------- | ----------- | ------------- |
322-
| n | n log n | n log n | n | No | Random-access |
322+
| n | n log n | n log n | n | No | Bidirectional |
323323

324324
This algorithm actually uses a rather big amount of memory but scales better than other O(n log n) algorithms of the library described as "slow" when the collections get bigger.
325325

326326
*New in version 1.10.0*
327327

328+
*Changed in version 1.12.1:* `slab_sorter` now works with bidirectional iterators.
329+
328330
### `smooth_sorter`
329331

330332
```cpp

docs/Tooling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ The same options exist without the `CPPSORT_` prefix exist, but are deprecated.
5151
conan search cpp-sort --remote=conan-center
5252
```
5353

54-
And then install any version to your local cache as follows (here with version 1.12.0):
54+
And then install any version to your local cache as follows (here with version 1.12.1):
5555

5656
```sh
57-
conan install cpp-sort/1.12.0
57+
conan install cpp-sort/1.12.1
5858
```
5959

6060
The packages downloaded from conan-center are minimal and only contain the files required to use **cpp-sort** as a library: the headers, CMake files and licensing information. If you need anything else you have to build your own package with the `conanfile.py` available in this repository.

docs/Writing-a-bubble_sorter.md

Lines changed: 111 additions & 95 deletions
Large diffs are not rendered by default.

examples/bubble_sorter.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2017 Morwenn
2+
* Copyright (c) 2015-2021 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <cstddef>
@@ -15,22 +15,18 @@
1515

1616
namespace detail
1717
{
18-
template<
19-
typename ForwardIterator,
20-
typename StrictWeakOrdering
21-
>
22-
auto bubble_sort(ForwardIterator first, std::size_t size,
23-
StrictWeakOrdering compare)
18+
template<typename ForwardIterator, typename Compare>
19+
auto bubble_sort(ForwardIterator first, std::size_t size, Compare compare)
2420
-> void
2521
{
2622
if (size < 2) return;
2723

2824
auto&& comp = cppsort::utility::as_function(compare);
2925

3026
while (--size) {
31-
ForwardIterator current = first;
32-
ForwardIterator next = std::next(current);
33-
for (std::size_t i = 0 ; i < size ; ++i) {
27+
auto current = first;
28+
auto next = std::next(current);
29+
for (std::size_t i = 0; i < size; ++i) {
3430
if (comp(*next, *current)) {
3531
using cppsort::utility::iter_swap;
3632
iter_swap(current, next);
@@ -46,18 +42,17 @@ namespace detail
4642
// Pair of iterators overload
4743
template<
4844
typename ForwardIterator,
49-
typename StrictWeakOrdering = std::less<>,
45+
typename Compare = std::less<>,
5046
typename = std::enable_if_t<not cppsort::is_projection_iterator_v<
51-
StrictWeakOrdering, ForwardIterator
47+
Compare, ForwardIterator
5248
>>
5349
>
54-
auto operator()(ForwardIterator first, ForwardIterator last,
55-
StrictWeakOrdering compare={}) const
50+
auto operator()(ForwardIterator first, ForwardIterator last, Compare compare={}) const
5651
-> void
5752
{
5853
static_assert(
5954
std::is_base_of<
60-
std::forward_iterator_tag,
55+
iterator_category,
6156
typename std::iterator_traits<ForwardIterator>::iterator_category
6257
>::value,
6358
"bubble_sorter requires at least forward iterators"
@@ -70,17 +65,17 @@ namespace detail
7065
// Iterable overload
7166
template<
7267
typename ForwardIterable,
73-
typename StrictWeakOrdering = std::less<>,
68+
typename Compare = std::less<>,
7469
typename = std::enable_if_t<not cppsort::is_projection_v<
75-
StrictWeakOrdering, ForwardIterable
70+
Compare, ForwardIterable
7671
>>
7772
>
78-
auto operator()(ForwardIterable&& iterable, StrictWeakOrdering compare={}) const
73+
auto operator()(ForwardIterable&& iterable, Compare compare={}) const
7974
-> void
8075
{
8176
static_assert(
8277
std::is_base_of<
83-
std::forward_iterator_tag,
78+
iterator_category,
8479
typename std::iterator_traits<decltype(std::begin(iterable))>::iterator_category
8580
>::value,
8681
"bubble_sorter requires at least forward iterators"
@@ -118,7 +113,7 @@ int main()
118113

119114
// Fill the collection in sorted order
120115
std::array<int, 8> collection;
121-
std::iota(std::begin(collection), std::end(collection), 0);
116+
std::iota(collection.begin(), collection.end(), 0);
122117

123118
// Projection to sort in descending order
124119
auto projection = [](int n) { return -n; };
@@ -130,6 +125,6 @@ int main()
130125
// Bubble sort the collection
131126
bubble_sort(to_sort, projection);
132127
// Check that it is sorted in descending order
133-
assert(std::is_sorted(std::begin(to_sort), std::end(to_sort), std::greater<>{}));
134-
} while (std::next_permutation(std::begin(collection), std::end(collection)));
128+
assert(std::is_sorted(to_sort.begin(), to_sort.end(), std::greater<>{}));
129+
} while (std::next_permutation(collection.begin(), collection.end()));
135130
}

include/cpp-sort/adapters/verge_adapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace cppsort
5151
{
5252
static_assert(
5353
std::is_base_of<
54-
std::random_access_iterator_tag,
54+
iterator_category,
5555
iterator_category_t<RandomAccessIterator>
5656
>::value,
5757
"verge_adapter requires at least random-access iterators"

0 commit comments

Comments
 (0)