26#ifndef LIBSEMIGROUPS_ORDER_HPP_
27#define LIBSEMIGROUPS_ORDER_HPP_
32#include <initializer_list>
39#include "exception.hpp"
110 template <
typename Thing,
111 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
114 x.cbegin(), x.cend(), y.cbegin(), y.cend());
144 template <
typename Thing>
147 x->cbegin(), x->cend(), y->cbegin(), y->cend());
183 template <
typename Thing>
184 [[nodiscard]]
bool operator()(Thing
const& x, Thing
const& y)
const {
208 template <
typename T>
238 template <
typename Iterator>
242 Iterator last2)
const {
286 template <
typename Iterator,
287 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
292 return (last1 - first1) < (last2 - first2)
293 || ((last1 - first1) == (last2 - first2)
327 template <
typename Thing,
328 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
363 template <
typename Thing>
399 template <
typename Thing>
400 [[nodiscard]]
bool operator()(Thing
const& x, Thing
const& y)
const {
441 template <
typename Iterator,
442 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
446 Iterator last2)
noexcept;
475 template <
typename Thing,
476 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
478 Thing
const& y)
noexcept {
510 template <
typename Thing>
512 Thing*
const y)
noexcept {
514 x->cbegin(), x->cend(), y->cbegin(), y->cend());
547 template <
typename Thing>
549 Thing
const& y)
const noexcept {
593 template <
typename Iterator,
594 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
641 template <
typename Thing,
642 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
648 x.cbegin(), x.cend(), y.cbegin(), y.cend(), weights);
690 template <
typename Thing>
696 x->cbegin(), x->cend(), y->cbegin(), y->cend(), weights);
739 template <
typename Iterator,
740 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
785 template <
typename Thing,
786 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
791 x.cbegin(), x.cend(), y.cbegin(), y.cend(), weights);
832 template <
typename Thing>
837 x->cbegin(), x->cend(), y->cbegin(), y->cend(), weights);
977 template <
typename Thing>
978 [[nodiscard]]
bool operator()(Thing
const& x, Thing
const& y)
const {
1007 template <
typename Thing>
1024 return _should_check;
1042 _should_check = val;
1119 template <
typename Iterator,
1120 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
1167 template <
typename Thing,
1168 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
1174 x.cbegin(), x.cend(), y.cbegin(), y.cend(), weights);
1216 template <
typename Thing>
1222 x->cbegin(), x->cend(), y->cbegin(), y->cend(), weights);
1265 template <
typename Iterator,
1266 typename = std::enable_if_t<!rx::is_input_or_sink_v<Iterator>>>
1311 template <
typename Thing,
1312 typename = std::enable_if_t<!rx::is_input_or_sink_v<Thing>>>
1316 return wt_lex_compare(x.cbegin(), x.cend(), y.cbegin(), y.cend(), weights);
1357 template <
typename Thing>
1362 x->cbegin(), x->cend(), y->cbegin(), y->cend(), weights);
1499 template <
typename Thing>
1500 [[nodiscard]]
bool operator()(Thing
const& x, Thing
const& y)
const {
1501 if (_should_check) {
1529 template <
typename Thing>
1546 return _should_check;
1564 _should_check = val;
bool lexicographical_compare(Thing const &x, Thing const &y)
Compare two objects of the same type using std::lexicographical_compare.
Definition order.hpp:112
bool wt_shortlex_compare(Iterator first1, Iterator last1, Iterator first2, Iterator last2, std::vector< size_t > const &weights)
Compare two objects of the same type using the weighted short-lex ordering and check validity.
bool wt_shortlex_compare_no_checks(Iterator first1, Iterator last1, Iterator first2, Iterator last2, std::vector< size_t > const &weights)
Compare two objects of the same type using the weighted short-lex ordering without checks.
bool wt_lex_compare_no_checks(Iterator first1, Iterator last1, Iterator first2, Iterator last2, std::vector< size_t > const &weights)
Compare two objects of the same type using the weighted lex ordering without checks.
bool wt_lex_compare(Iterator first1, Iterator last1, Iterator first2, Iterator last2, std::vector< size_t > const &weights)
Compare two objects of the same type using the weighted lex ordering and check validity.
bool shortlex_compare(Iterator first1, Iterator last1, Iterator first2, Iterator last2)
Compare two objects of the same type using the short-lex reduction ordering.
Definition order.hpp:288
bool recursive_path_compare(Iterator first1, Iterator last1, Iterator first2, Iterator last2) noexcept
Compare two objects of the same type using the recursive path comparison.
Order
The possible orderings of words and strings.
Definition order.hpp:54
@ none
No ordering.
Definition order.hpp:56
@ shortlex
Definition order.hpp:60
@ lex
Definition order.hpp:65
@ recursive
Definition order.hpp:69
T lexicographical_compare(T... args)
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
A stateless struct with binary call operator using std::lexicographical_compare.
Definition order.hpp:163
bool operator()(Thing const &x, Thing const &y) const
Call operator that compares x and y using std::lexicographical_compare.
Definition order.hpp:184
bool operator()(std::initializer_list< T > x, std::initializer_list< T > y) const
Call operator that compares x and y given initializer lists using std::lexicographical_compare.
Definition order.hpp:209
bool operator()(Iterator first1, Iterator last1, Iterator first2, Iterator last2) const
Call operator that compares iterators using std::lexicographical_compare.
Definition order.hpp:239
A stateless struct with binary call operator using recursive_path_compare.
Definition order.hpp:530
bool operator()(Thing const &x, Thing const &y) const noexcept
Call operator that compares x and y using recursive_path_compare.
Definition order.hpp:548
A stateless struct with binary call operator using shortlex_compare.
Definition order.hpp:380
bool operator()(Thing const &x, Thing const &y) const
Call operator that compares x and y using shortlex_compare.
Definition order.hpp:400
static constexpr bool checks
Constant to enable validity checks.
Definition order.hpp:1392
WtLexCompare & should_check(bool val) noexcept
Set the value of the constructor parameter should_check.
Definition order.hpp:1563
WtLexCompare & init(std::vector< size_t > &&weights, bool should_check)
Reinitialize an existing WtLexCompare object.
Definition order.hpp:1464
bool operator()(Thing const &x, Thing const &y) const
Call operator that compares x and y using either wt_lex_compare or wt_lex_compare_no_checks.
Definition order.hpp:1500
WtLexCompare & weights(std::vector< size_t > const &val)
Set the weights.
Definition order.hpp:1589
WtLexCompare & init(std::vector< size_t > const &weights, bool should_check)
Reinitialize an existing WtLexCompare object.
Definition order.hpp:1429
WtLexCompare(std::vector< size_t > &&weights, bool should_check)
Construct from weights vector rvalue reference and specify whether or not the call operator should ch...
Definition order.hpp:1449
bool call_no_checks(Thing const &x, Thing const &y) const
Call operator that does no checks.
Definition order.hpp:1530
std::vector< size_t > const & weights() const noexcept
Returns the weights.
Definition order.hpp:1577
WtLexCompare(std::vector< size_t > const &weights, bool should_check)
Construct from weights vector reference and specify whether or not the call operator should check its...
Definition order.hpp:1414
bool should_check() const noexcept
Returns the value of the constructor parameter should_check.
Definition order.hpp:1545
static constexpr bool no_checks
Constant to disable validity checks.
Definition order.hpp:1398
static constexpr bool checks
Constant to enable validity checks.
Definition order.hpp:868
WtShortLexCompare(std::vector< size_t > &&weights, bool should_check)
Construct from weights vector rvalue reference and specify whether or not the call operator should ch...
Definition order.hpp:926
bool operator()(Thing const &x, Thing const &y) const
Call operator that compares x and y using either wt_shortlex_compare or wt_shortlex_compare_no_checks...
Definition order.hpp:978
WtShortLexCompare & init(std::vector< size_t > &&weights, bool should_check)
Reinitialize an existing WtShortLexCompare object.
Definition order.hpp:941
WtShortLexCompare(std::vector< size_t > const &weights, bool should_check)
Construct from weights vector reference and specify whether or not the call operator should check its...
Definition order.hpp:890
bool call_no_checks(Thing const &x, Thing const &y) const
Call operator that does no checks.
Definition order.hpp:1008
std::vector< size_t > const & weights() const noexcept
Returns the weights.
Definition order.hpp:1055
WtShortLexCompare & init(std::vector< size_t > const &weights, bool should_check)
Reinitialize an existing WtShortLexCompare object.
Definition order.hpp:905
bool should_check() const noexcept
Returns the value of the constructor parameter should_check.
Definition order.hpp:1023
WtShortLexCompare & should_check(bool val) noexcept
Set the value of the constructor parameter should_check.
Definition order.hpp:1041
WtShortLexCompare & weights(std::vector< size_t > const &val)
Set the weights.
Definition order.hpp:1070
static constexpr bool no_checks
Constant to disable validity checks.
Definition order.hpp:874