Lexical sort
Interface for lexical sort with tolerance.
Functions
-
template<typename T>
Comparator<T> makeComparator(LexicalComparator<T> const &lexical_comp) Create a Comparator with template deduction.
- Template Parameters:
T – the type of elements to compare
- Parameters:
lexical_comp – The original LexicalComparator
- Returns:
a Comparator for strict comparison using lexical_comp
-
template<typename it_comparator, typename it_to_sort>
void lexical_sort(it_comparator cur_comp, it_comparator end_comp, it_to_sort start, it_to_sort end) Sort in lexical order using a list of LexicalComparators.
Values are sorted in strict mode according to the first comparator before being regrouped by equivalcence group. An equivalence group is defined such that all elements of the group are considered equal by the comparator.
Once the equivalence groups have been defined, they are sorted according to the second criterion, before being grouped again into sub-equivalence groups, and so on.
Note
it_comparator must be an iterator on LexicalComparator<T> (smart) pointers
Note
it_to_sort must be an iterator on T values.
- Template Parameters:
it_comparator – type of iterator for range of LexicalComparator
it_to_sort – type of iterator for range of elements to sort
- Parameters:
cur_comp – begin iterator for range of LexicalComparator
end_comp – end iterator for range of LexicalComparator
start – begin iterator for range of elements to sort
end – end iterator for range of elements to sort
-
template<typename T>
struct LexicalComparator - #include <lexical_sort.hh>
Interface for lexical comparator.
Must implement two functions :
is_better : strict comparison (without tolerance) return true if left hand side is better than right hand side
is_equivalent : comparison with tolerance return true if both sides are equivalent
- Template Parameters:
T – type of elements to compare
-
template<typename T>
struct Comparator - #include <lexical_sort.hh>
Comparator for strict comparison.
- Template Parameters:
T – the type of elements to compare
Public Functions
-
inline explicit Comparator(LexicalComparator<T> const *cmp)
Constructor.
Public Members
-
LexicalComparator<T> const *internal_cmp = nullptr
Pointer to original LexicalComparator.