You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Benchmarks.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ All of the graphs on this page have been generated with slightly modified versio
15
15
16
16
*The latest benchmarks were run on Windows 10 with 64-bit MinGW-w64 g++12.0, with the flags -O3 -march=native -std=c++20.*
17
17
18
-
# Random-access iterables
18
+
# Random-access collections
19
19
20
20
Most sorting algorithms are designed to work with random-access iterators, so this section is deemed to be bigger than the other ones. Note that many of the algorithms work better with contiguous iterators; the results for `std::vector` and `std::deque` are probably different.
21
21
@@ -76,7 +76,7 @@ The analysis is pretty simple here:
76
76
* As a result `smooth_sort` and `poplar_sort` beat each other depending on the type of the collection to sort.
77
77
* Slabsort has an unusual graph: even for shuffled data it might end up beating `heap_sort` when the collection becomes big enough.
78
78
79
-
# Bidirectional iterables
79
+
# Bidirectional collections
80
80
81
81
Sorting algorithms that handle non-random-access iterators are often second class citizens, but **cpp-sort** still provides a few ones. The most interesting part is that we can see how generic sorting algorithms perform compared to algorithms such as [`std::list::sort`][std-list-sort] which are aware of the data structure they are sorting.
82
82
@@ -92,14 +92,14 @@ For elements as small as `double`, there are two clear winners here: `drop_merge
92
92
*`quick_sort` and `quick_merge_sort` are good enough contenders when trying to avoid heap memory allocations.
93
93
*`mel_sort` is bad.
94
94
95
-
# Forward iterables
95
+
# Forward collections
96
96
97
97
Even fewer sorters can handle forward iterators. `out_of_place_adapter(pdq_sort)` was not included in the patterns benchmark, because it adapts to patterns the same way `pdq_sort` does.
98
98
99
99

100
100

101
101
102
-
The results are roughly the same than with bidirectional iterables:
102
+
The results are roughly the same than with bidirectional collections:
103
103
* Sorting out-of-place is faster than anything else.
104
104
*[`std::forward_list::sort`][std-forward-list-sort] doesn't scale well when moves are inexpensive.
105
105
*`quick_sort` and `quick_merge_sort` are good enough contenders when trying to avoid heap memory allocations.
Copy file name to clipboardExpand all lines: docs/Comparators.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,15 +64,15 @@ Partial order comparators are considered as [generating branchless code][branchl
64
64
#include<cpp-sort/comparators/natural_less.h>
65
65
```
66
66
67
-
The comparator `natural_less` is a [customization point][custom-point] that can be used to perform a [natural sort][natural-sort]. The function handles any two forward iterable sequences of `char` out of the box using [`std::isdigit`][std-is-digit] to identify digits (which includes `std::string`, `std::vector<char>` and `char[]`). Other character types and locales are currently not handled and it is unlikely that the library will evolve more than switching to `<locale>`'s `std::isdigit` instead of `<cctype>`'s one.
67
+
The comparator `natural_less` is a [customization point][custom-point] that can be used to perform a [natural sort][natural-sort]. The function handles any two forward ranges of `char` out of the box using [`std::isdigit`][std-is-digit] to identify digits (which includes `std::string`, `std::vector<char>` and `char[]`). Other character types and locales are currently not handled and it is unlikely that the library will evolve more than switching to `<locale>`'s `std::isdigit` instead of `<cctype>`'s one.
The comparator `case_insensitive_less` is a [customization point][custom-point] that be used to perform a [case-insensitive][case-sensitivity] sort on collections. The function handles any forward iterable sequence of `char` or `wchar_t` out of the box using [`std::ctype::tolower`][to-lower] prior to character comparison. The customization point has two distinct signatures:
75
+
The comparator `case_insensitive_less` is a [customization point][custom-point] that be used to perform a [case-insensitive][case-sensitivity] sort on collections. The function handles any forward range of `char` or `wchar_t` out of the box using [`std::ctype::tolower`][to-lower] prior to character comparison. The customization point has two distinct signatures:
Copy file name to clipboardExpand all lines: docs/Fixed-size-sorters.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Fixed-size sorters, sometimes called *fixed sorters* for simplicity are a special kind of sorters designed to sort a fixed number of values. Their `operator()` also takes either an iterable or a pair of iterators as well as an optional comparison and projection functions. Most of the time the end iterator is unused, but future versions of the library may start to use it to optionally perform bound-checking.
1
+
Fixed-size sorters, sometimes called *fixed sorters* for simplicity are a special kind of sorters designed to sort a fixed number of values. Their `operator()` also takes either a range or a pair of iterators as well as an optional comparison and projection functions. Most of the time the end iterator is unused, but future versions of the library may start to use it to optionally perform bound-checking.
2
2
3
3
Fixed-size sorters are not actual sorters *per se* but class templates that take an `std::size_t` template parameter. Every valid specialization of a fixed-size sorter for a given size yields a "valid" sorter. Several fixed-size sorters have specializations for some sizes only and will trigger a compile-time error when one tries to instantiate a specialization which is not part of the fixed-size sorter's domain (the domain corresponds to the set of valid specializations). Information about fixed-size sorters can be obtained via [`fixed_sorter_traits`][fixed-sorter-traits]. One can also make sure that a given fixed-size sorter is automatically used to sort small fixed-size arrays thanks to [`small_array_adapter`][small-array-adapter].
Copy file name to clipboardExpand all lines: docs/Library-nomenclature.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@
40
40
41
41
**Proxy iterator*: sometimes `std::move` and `std::swap` are not enough to correctly move values around, and we need to know more about the iterators in order to perform the appropriate operation. It's typically the case with proxy iterators: iterators whose `reference` type is not actually a reference type (*e.g.*`std::vector<bool>::reference`). Traditional algorithms don't play well with these types, however there are [standard proposals][p0022] to solve the problem by introducing a function named `iter_move` and making it as well as `iter_swap` customization points. No proposal has been accepted yet, so standard libraries don't handle proxy iterators; however every sorter in **cpp-sort** can actually handle such iterators (except `std_sorter` and `std_stable_sorter`). The library exposes the functions [`utility::iter_move` and `utility::iter_swap`][utility-iter-move] in case you also need to make your own algorithms handle proxy iterators.
42
42
43
-
**Sorter*: [sorters][sorters] are the protagonists in this library. They are function objects implementing specific sorting algorithms. Their `operator()` is overloaded so that it can handle iterables or pairs of iterators, and conditionally overloaded so that it can handle user-provided comparison and/or projection functions (see *unified sorting interface*).
43
+
**Sorter*: [sorters][sorters] are the protagonists in this library. They are function objects implementing specific sorting algorithms. Their `operator()` is overloaded so that it can handle ranges or pairs of iterators, and conditionally overloaded so that it can handle user-provided comparison and/or projection functions (see *unified sorting interface*).
**Type-specific sorter*: some non-comparison sorters such as the [`spread_sorter`][spread-sorter] implement specific sorting algorithms which only work with some specific types (for example integers or strings).
67
67
68
-
**Unified sorting interface*: *sorters*, *sorter adapters*, *measures of presortedness* and a few other components of the library accept an iterable or a pair of iterators, and optionally a comparison function and/or a comparison function. Those components typically rely on the library's [`sorter_facade`][sorter-facade] which handles the dispatching to the component's implementation and to handle a number of special cases. For simplicity, what is accepted by the `operator()` of such components is referred to as the *unified sorting interface* in the rest of the library.
68
+
**Unified sorting interface*: *sorters*, *sorter adapters*, *measures of presortedness* and a few other components of the library accept a range or a pair of iterators, and optionally a comparison function and/or a comparison function. Those components typically rely on the library's [`sorter_facade`][sorter-facade] which handles the dispatching to the component's implementation and to handle a number of special cases. For simplicity, what is accepted by the `operator()` of such components is referred to as the *unified sorting interface* in the rest of the library.
Copy file name to clipboardExpand all lines: docs/Measures-of-presortedness.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ The measures of presortedness in bold in the graph are available in **cpp-sort**
37
37
38
38
## Measures of presortedness in cpp-sort
39
39
40
-
In **cpp-sort**, measures of presortedness are implemented as instances of some specific function objects. They take an iterable or a pair of iterators and return how much disorder there is in the sequence according to the measure. Measures of presortedness follow the *unified sorting interface*, allowing a certain degree a freedom in the parameters they accept:
40
+
In **cpp-sort**, measures of presortedness are implemented as instances of some specific function objects. They take a range or a pair of iterators and return how much disorder there is in the sequence according to the measure. Measures of presortedness follow the *unified sorting interface*, allowing a certain degree a freedom in the parameters they accept:
41
41
42
42
```cpp
43
43
usingnamespacecppsort;
@@ -146,7 +146,7 @@ Computes the minimum number of exchanges required to sort *X*, which corresponds
146
146
147
147
`max_for_size`: |*X*| - 1 when every element in *X* is one element away from its sorted position.
148
148
149
-
*Warning: this algorithm might be noticeably slower when the passed iterable is not random-access.*
149
+
*Warning: this algorithm might be noticeably slower when the passed range is not random-access.*
auto apply_permutation(RandomAccessRange1&& range, RandomAccessRange2&& indices)
39
39
-> void;
40
40
```
41
41
@@ -375,7 +375,7 @@ auto m = get<foo_tag>(mm);
375
375
376
376
***WARNING:** this header is removed in version 3.0.0, use `mstd::distance` instead.*
377
377
378
-
`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.
378
+
`size` is a function that can be used to get the size of a container. It is equivalent to the C++17 function [`std::size`][std-size] but has an additional tweak so that, if the container is not a fixed-size C array and doesn't have a `size` method, it calls `std::distance(std::begin(cont), std::end(cont))` on the container. Therefore, this function can also be used for `std::forward_list` as well as some views.
Copy file name to clipboardExpand all lines: docs/Sorter-adapters.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,7 +172,7 @@ template<typename Sorter>
172
172
structself_sort_adapter;
173
173
```
174
174
175
-
Since it is impossible to guarantee the stability of the `sort` method of a given iterable, the *resulting sorter*'s `is_always_stable` is `std::false_type`. However, [`is_stable`][is-stable]will be `std::true_type`if a container's `stable_sort` is called or if a call to the *adapted sorter* is stable. A special case considers valid calls to `std::list::sort` and `std::forward_list::sort` to be stable.
175
+
Since it is impossible to guarantee the stability of the `sort` method of a given container, the *resulting sorter*'s `is_always_stable` is `std::false_type`. However, [`is_stable`][is-stable]is `std::true_type`when a container's `stable_sort` is called or if a call to the *adapted sorter* is stable. It is special-cased to consider calls to `std::list::sort` and `std::forward_list::sort` to be stable.
0 commit comments