Sequoia
Loading...
Searching...
No Matches
Functions | Variables
Algorithms.hpp File Reference

A collection of constexpr algorithms. More...

#include "sequoia/Core/Meta/Concepts.hpp"
#include <algorithm>
#include <functional>
#include <iterator>

Go to the source code of this file.

Functions

template<class Iter , class Comp = std::ranges::less, class Proj = std::identity>
constexpr void sequoia::bubble_up (Iter begin, Iter current, Comp comp={}, Proj proj={})
 
template<class Iter , class Comp = std::ranges::less, class Proj = std::identity>
constexpr void sequoia::bubble_down (Iter begin, Iter current, Iter end, Comp comp={}, Proj proj={})
 
template<class Iter , class Comp = std::ranges::less, class Proj = std::identity>
constexpr void sequoia::make_heap (Iter begin, Iter end, Comp comp={}, Proj proj={})
 
template<class Iter , class Comp = std::ranges::less, class Proj = std::identity>
constexpr void sequoia::sort (Iter begin, Iter end, Comp comp={}, Proj proj={})
 
template<std::input_iterator Iter, std::weakly_incrementable OutIter, class Comp = std::ranges::less, class Proj = std::identity>
requires merge_sortable<Iter, Comp, Proj>
constexpr void sequoia::stable_sort (Iter first, Iter last, OutIter out, Comp compare={}, Proj proj={})
 
template<std::input_iterator Iter, class Comp = std::ranges::less, class Proj = std::identity>
requires merge_sortable<Iter, Comp, Proj>
constexpr void sequoia::stable_sort (Iter first, Iter last, Comp compare={}, Proj proj={})
 
template<std::forward_iterator Iter, class Comp = std::ranges::equal_to, class Proj = std::identity>
requires clusterable<Iter, Comp, Proj>
constexpr void sequoia::cluster (Iter begin, Iter end, Comp comp={}, Proj proj={})
 An algorithm which clusters together elements which compare equal.
 

Variables

template<class Iter , class Comp , class Proj >
constexpr bool sequoia::merge_sortable
 
template<class Iter , class Comp , class Proj >
constexpr bool sequoia::clusterable
 

Detailed Description

A collection of constexpr algorithms.

Function Documentation

◆ cluster()

template<std::forward_iterator Iter, class Comp = std::ranges::equal_to, class Proj = std::identity>
requires clusterable<Iter, Comp, Proj>
constexpr void sequoia::cluster ( Iter  begin,
Iter  end,
Comp  comp = {},
Proj  proj = {} 
)
constexpr

An algorithm which clusters together elements which compare equal.

This is best used in situations where operator< is not defined.

◆ sort()

template<class Iter , class Comp = std::ranges::less, class Proj = std::identity>
constexpr void sequoia::sort ( Iter  begin,
Iter  end,
Comp  comp = {},
Proj  proj = {} 
)
constexpr

This version of swap is retained, at least for now, since it is guaranteed to use ranges::iter_swap internally. This means that the behaviour can be customized by overloading iter_swap. Currently, this is exploited to sort graph nodes. This needs further thought, not least since ranges::advance etc cannot be used in the implementation

Variable Documentation

◆ clusterable

template<class Iter , class Comp , class Proj >
constexpr bool sequoia::clusterable
inlineconstexpr
Initial value:
{
std::forward_iterator<Iter>
&& requires(std::iter_reference_t<Iter> r, Comp comp, Proj proj){
{ comp(proj(r), proj(r)) } -> std::convertible_to<bool>;
}
}

◆ merge_sortable

template<class Iter , class Comp , class Proj >
constexpr bool sequoia::merge_sortable
inlineconstexpr
Initial value:
{
requires{
typename std::iterator_traits<Iter>::value_type;
requires (std::is_copy_constructible_v<typename std::iterator_traits<Iter>::value_type> || is_initializable_v<typename std::iterator_traits<Iter>::value_type>);
}
&& std::mergeable<Iter, Iter, typename std::vector<typename std::iterator_traits<Iter>::value_type>::iterator, Comp, Proj, Proj>
}