Template Function sequant::bubble_sort_parity

Function Documentation

template<std::ranges::range Range, typename Compare = std::less<>>
int sequant::bubble_sort_parity(Range &&rng, Compare comp = {})

sorts rng in place with bubble_sort and returns the parity of the sorting permutation

Note

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