1
- [ ![ Latest Release] ( https://img.shields.io/badge/release-2.1 .0-blue.svg )] ( https://github.com/timsort/cpp-TimSort/releases/tag/v2.1 .0 )
2
- [ ![ Conan Package] ( https://img.shields.io/badge/conan-cpp--TimSort%2F2.1 .0-blue.svg )] ( https://conan.io/center/timsort?version=2.1 .0 )
1
+ [ ![ Latest Release] ( https://img.shields.io/badge/release-3.0 .0-blue.svg )] ( https://github.com/timsort/cpp-TimSort/releases/tag/v3.0 .0 )
2
+ [ ![ Conan Package] ( https://img.shields.io/badge/conan-cpp--TimSort%2F3.0 .0-blue.svg )] ( https://conan.io/center/timsort?version=3.0 .0 )
3
3
[ ![ Pitchfork Layout] ( https://img.shields.io/badge/standard-PFL-orange.svg )] ( https://github.com/vector-of-bool/pitchfork )
4
4
5
5
## TimSort
@@ -10,20 +10,26 @@ See also the following links for a detailed description of TimSort:
10
10
* http://svn.python.org/projects/python/trunk/Objects/listsort.txt
11
11
* http://en.wikipedia.org/wiki/Timsort
12
12
13
- This library requires at least C++11. If you need a C++98 version, you can check the 1.x.y branch of this repository.
14
-
15
- According to the benchmarks, ` gfx::timsort ` is slower than [ ` std::sort() ` ] [ std-sort ] on randomized sequences, but
16
- faster on partially-sorted ones. It can be used as a drop-in replacement for [ ` std::stable_sort ` ] [ std-stable-sort ] ,
17
- with the difference that it can't fallback to a O(n log² n) algorithm when there isn't enough extra heap memory
13
+ This version of the library requires at least C++20. Older versions of the library, available in different branches,
14
+ offer support for older standards though implement fewer features:
15
+ * Branch ` 2.x.y ` is compatible with C++11, and is slightly more permissive in some reagard due to the lack of
16
+ concepts to constrain its interface (it notaby supports iterators without postfix operator++/--).
17
+ * Branch ` 1.x.y ` is compatible with C++03.
18
+ Older versions are not actively maintained anymore. If you need extended support for those, please open specific
19
+ issues for the problems you want solved.
20
+
21
+ According to the benchmarks, ` gfx::timsort ` is slower than [ ` std::ranges::sort ` ] [ std-sort ] on randomized sequences,
22
+ but faster on partially-sorted ones. It can be used as a drop-in replacement for [ ` std::ranges::stable_sort ` ] [ std-stable-sort ] ,
23
+ with the difference that it can't fall back to a O(n log² n) algorithm when there isn't enough extra heap memory
18
24
available.
19
25
20
26
Merging sorted ranges efficiently is an important part of the TimSort algorithm. This library exposes ` gfx::timmerge `
21
- in the public API, a drop-in replacement for [ ` std::inplace_merge ` ] [ std-inplace-merge ] with the difference that it
22
- can't fallback to a O(n log n) algorithm when there isn't enough extra heap memory available. According to the
23
- benchmarks, ` gfx::timmerge ` is slower than ` std::inplace_merge ` on heavily/randomly overlapping subranges of simple
24
- elements, but it is faster for complex elements such as ` std::string ` and on sparsely overlapping subranges.
27
+ in the public API, a drop-in replacement for [ ` std::ranges:: inplace_merge ` ] [ std-inplace-merge ] with the difference
28
+ that it can't fall back to a O(n log n) algorithm when there isn't enough extra heap memory available. According to
29
+ the benchmarks, ` gfx::timmerge ` is slower than ` std::ranges:: inplace_merge ` on heavily/randomly overlapping subranges
30
+ of simple elements, but it is faster for complex elements such as ` std::string ` , and on sparsely overlapping subranges.
25
31
26
- The list of available signatures is as follows ( in namespace ` gfx ` ) :
32
+ The ibrary exposes the following functions in namespace ` gfx ` :
27
33
28
34
``` cpp
29
35
// timsort
@@ -74,7 +80,8 @@ auto timmerge(Range &&range, std::ranges::iterator_t<Range> middle,
74
80
75
81
## EXAMPLE
76
82
77
- Example of using timsort with a comparison function and a projection function to sort a vector of strings by length:
83
+ Example of using timsort with a defaulted comparison function and a projection function to sort a vector of strings
84
+ by length:
78
85
79
86
```cpp
80
87
#include <string>
@@ -92,31 +99,28 @@ gfx::timsort(collection, {}, &len);
92
99
93
100
## INSTALLATION & COMPATIBILITY
94
101
95
- ![ Ubuntu builds status] ( https://github.com/timsort/cpp-TimSort/workflows/Ubuntu%20Builds/badge.svg?branch=master )
96
- ![ Windows builds status] ( https://github.com/timsort/cpp-TimSort/workflows/Windows%20Builds/badge.svg?branch=master )
97
- ![ MacOS builds status] ( https://github.com/timsort/cpp-TimSort/workflows/MacOS%20Builds/badge.svg?branch=master )
98
-
99
- The library has been tested with the following compilers:
100
- * GCC 5.5
101
- * Clang 6
102
- * MSVC 2017
102
+ [ ![ Ubuntu Builds] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-ubuntu.yml/badge.svg?branch=3.x.y )] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-ubuntu.yml )
103
+ [ ![ MSVC Builds] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-msvc.yml/badge.svg?branch=3.x.y )] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-msvc.yml )
104
+ [ ![ MinGW-w64 Builds] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-mingw.yml/badge.svg?branch=3.x.y )] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-mingw.yml )
105
+ [ ![ MacOS Builds] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-macos.yml/badge.svg?branch=3.x.y )] ( https://github.com/timsort/cpp-TimSort/actions/workflows/build-macos.yml )
103
106
104
- It should also work with more recent compilers, and most likely with some older compilers too. We used to guarantee
105
- support as far back as Clang 3.8, but the new continuous integration environment doesn't go that far back.
107
+ The library is tested with the following compilers:
108
+ * Ubuntu: GCC 10, Clang 11
109
+ * Windows: MSVC 19.37.32826.1, MinGW-w64 GCC 12
110
+ * MacOS: GCC 10, Clang 17
106
111
107
- The library can be installed on the system via CMake with the following commands:
112
+ The library can be installed on the system via [ CMake] [ cmake ] (at least 3.14) with the following commands:
108
113
109
114
``` sh
110
- cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
111
- cd build
112
- make install
115
+ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
116
+ cmake --install build
113
117
```
114
118
115
- Alternatively the library is also available on conan-center-index and can be installed in your local Conan cache via
116
- the following command:
119
+ Alternatively the library is also available [ Conan Center ] [ conan-center ] and can be directly installed in your local
120
+ [ Conan ] [ conan ] cache with the following command:
117
121
118
122
``` sh
119
- conan install timsort/2.1 .0
123
+ conan install --requires= timsort/3.0 .0
120
124
```
121
125
122
126
## DIAGNOSTICS & INFORMATION
@@ -142,16 +146,16 @@ GFX_TIMSORT_VERSION_PATCH
142
146
143
147
The tests are written with Catch2 and can be compiled with CMake and run through CTest.
144
148
145
- When using the project's main ` CMakeLists.txt ` , the CMake variable ` BUILD_TESTING ` is ` ON ` by default unless the
146
- project is included as a subdirectory. The following CMake variables are available to change the way the tests are
149
+ When using the project's main ` CMakeLists.txt ` , the CMake option ` BUILD_TESTING ` is ` ON ` by default unless the
150
+ project is included as a subdirectory. The following CMake options are available to change the way the tests are
147
151
built with CMake:
148
152
* ` GFX_TIMSORT_USE_VALGRIND ` : if ` ON ` , the tests will be run through Valgrind (` OFF ` by default)
149
153
* ` GFX_TIMSORT_SANITIZE ` : this variable takes a comma-separated list of sanitizers options to run the tests (empty by default)
150
154
151
155
## BENCHMARKS
152
156
153
- Benchmarks are available in the ` benchmarks ` subdirectory, and can be constructed directly by passing ` BUILD_BENCHMARKS=ON `
154
- variable to CMake during the configuration step.
157
+ Benchmarks are available in the ` benchmarks ` subdirectory, and can be constructed directly by passing the option
158
+ ` -DBUILD_BENCHMARKS=ON ` to CMake during the configuration step.
155
159
156
160
Example bench_sort output (timing scale: sec.):
157
161
@@ -222,6 +226,9 @@ Detailed bench_merge results for different middle iterator positions can be foun
222
226
https://github.com/timsort/cpp-TimSort/wiki/Benchmark-results
223
227
224
228
225
- [ std-inplace-merge ] : https://en.cppreference.com/w/cpp/algorithm/inplace_merge
226
- [ std-sort ] : https://en.cppreference.com/w/cpp/algorithm/sort
227
- [ std-stable-sort ] : https://en.cppreference.com/w/cpp/algorithm/stable_sort
229
+ [ cmake ] : https://cmake.org/
230
+ [ conan ] : https://conan.io/
231
+ [ conan-center ] : https://conan.io/center
232
+ [ std-inplace-merge ] : https://en.cppreference.com/w/cpp/algorithm/ranges/inplace_merge
233
+ [ std-sort ] : https://en.cppreference.com/w/cpp/algorithm/ranges/sort
234
+ [ std-stable-sort ] : https://en.cppreference.com/w/cpp/algorithm/ranges/stable_sort
0 commit comments