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 )
33[ ![ Pitchfork Layout] ( https://img.shields.io/badge/standard-PFL-orange.svg )] ( https://github.com/vector-of-bool/pitchfork )
44
55## TimSort
@@ -10,20 +10,26 @@ See also the following links for a detailed description of TimSort:
1010* http://svn.python.org/projects/python/trunk/Objects/listsort.txt
1111* http://en.wikipedia.org/wiki/Timsort
1212
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
1824available.
1925
2026Merging 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.
2531
26- The list of available signatures is as follows ( in namespace ` gfx ` ) :
32+ The ibrary exposes the following functions in namespace ` gfx ` :
2733
2834``` cpp
2935// timsort
@@ -74,7 +80,8 @@ auto timmerge(Range &&range, std::ranges::iterator_t<Range> middle,
7480
7581## EXAMPLE
7682
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:
7885
7986```cpp
8087#include <string>
@@ -92,31 +99,28 @@ gfx::timsort(collection, {}, &len);
9299
93100## INSTALLATION & COMPATIBILITY
94101
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 )
103106
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
106111
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:
108113
109114``` 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
113117```
114118
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:
117121
118122``` sh
119- conan install timsort/2.1 .0
123+ conan install --requires= timsort/3.0 .0
120124```
121125
122126## DIAGNOSTICS & INFORMATION
@@ -142,16 +146,16 @@ GFX_TIMSORT_VERSION_PATCH
142146
143147The tests are written with Catch2 and can be compiled with CMake and run through CTest.
144148
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
147151built with CMake:
148152* ` GFX_TIMSORT_USE_VALGRIND ` : if ` ON ` , the tests will be run through Valgrind (` OFF ` by default)
149153* ` GFX_TIMSORT_SANITIZE ` : this variable takes a comma-separated list of sanitizers options to run the tests (empty by default)
150154
151155## BENCHMARKS
152156
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.
155159
156160Example bench_sort output (timing scale: sec.):
157161
@@ -222,6 +226,9 @@ Detailed bench_merge results for different middle iterator positions can be foun
222226https://github.com/timsort/cpp-TimSort/wiki/Benchmark-results
223227
224228
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