There is a newer version of the record available.

Published February 2, 2020 | Version 1.6.0
Software Open

Morwenn/cpp-sort: 1.6.0 — Brunch

  • 1. @conan-io

Description

I didn't have the opportunity to brunch properly since my trip to Scotland back in August where I could enjoy tasty local breakfasts at unreasonable hours - with today's excellent vegetarian brunch that cycle is complete and I can publish a new cpp-sort release.

New features

A new spin_sorter has been added to the library, based on the algorithm from Boost.Sort. Spinsort is a stable mergesort derivative which is often faster than the other available stable sorting algorithms. It is a stable comparison sorting algorithm that runs in O(n log n) and requires O(n) additional memory; unlike other algorithms in the library it doesn't have a fallback when there isn't enough extra memory available to merge runs.

As can be seen in the benchmark result above (sorting a std::vector<long double> with 10^7 elements) it tends to be the fastest of the stable sorts for random data, and is otherwise adaptive when some presortedness exists in the data to sort.

Bug fixes
  • Fixed a long-standing out-of-bounds issue in tim_sorter, which sometimes triggered Valgrind diagnostics when trying to sort an std::deque (issue #89).
  • Fixed an ODR issue in hybrid_adapter that triggered a compile-time issue with Clang 9 (issue #158).
  • Fixed an unsigned integer overflow in poplar_sorter that triggered a diagnostic with the undefined behaviour sanitizer.
  • Fixed a static_assert that wasn't strict enough in verge_adapter.
Improvements
  • The library doesn't have naked assert anymore: you now need to define the preprocessor flag CPPSORT_ENABLE_ASSERTIONS explicitly in order to enable assertions. This flag still honours the NDEBUG macro.
  • When verge_sorter is used to sort bidirectional iterators, it now falls back to quick_merge_sorter instead of quick_sorter to sort sections of the data to sort where runs aren't big enough. This lowers the complexity from O(n²) to O(n log n log log n) with a worst case of O(log n log n) space - the complexity's worst case shifts from the fallback to the vergesort layer itself. The vergesort layer still uses O(n) memory when it finds patterns to optimize.
  • counting_sorter is now able to sort collections of [un]signed __int128, even when the standard library is not properly instrumented to support them.
  • Algorithms relying on uninitialized_move may be faster when sorting trivial types. Affected sorters: block_sorter, merge_insertion_sorter, merge_sorter, spin_sorter, tim_sorter and verge_sorter.
  • Fewer copies of comparison and projection functions are performed when using stateful sorters.
Tooling

There has been some overarching CMake and Conan cleanups for this release: cpp-sort is notably available on Conan Center now, and the built-in Conan support has been reduced and should only be used by people willing to package their own version of the library.

  • cpp-sort can now be used as a CMake subproject with add_subdirectory without triggering errors.
  • New CMake option BUILD_EXAMPLES (OFF by default).
  • CMake: fixed flags in Debug builds.
  • Examples are now built during CI to avoid breaking them and forgetting about them.
  • The wiki now has a section dedicated to tooling, which currently contains some information about the CMake and Conan integration of the library.
  • Improved test coverage for sorters that can handle forward and bidirectional iterators.
  • Added tests to ensure that the library's algorithms marked as such can work even when no heap memory is available.
  • Added tests for algorithms that special cases to handle int128.
Known bugs

I didn't manage to fix every bug I could find since the previous release, so you might want to check the list of known bugs.

Files

Morwenn/cpp-sort-1.6.0.zip

Files (592.9 kB)

Name Size Download all
md5:c90c88e3f83f33ace3c1fb79b6b58210
592.9 kB Preview Download

Additional details

Related works