Template Function sequant::bubble_sort_parity¶
Defined in File algorithm.hpp
Function Documentation¶
-
template<std::ranges::range Range, typename Compare = std::less<>>
int sequant::bubble_sort_parity(Range &&rng, Compare comp = {})¶ sorts
rngin place with bubble_sort and returns the parity of the sorting permutationNote
resets the thread-local swap counter of the element type
- Parameters:
rng – a range whose element swaps are counted, i.e. elements are SwapCountable, SwapCountableRef, or have a counting swap (e.g. Index)
comp – a less-than relationship that specifies a weak order
- Returns:
+1 if an even number of swaps was performed, -1 otherwise