Defined in order.hpp.
A stateful struct with binary call operator using wt_shortlex_compare or wt_shortlex_compare_no_checks, depending on the value of the constructor parameter should_check. This struct stores a copy of a weights vector and can be used as a template parameter for standard library containers or algorithms that require a comparison functor.
should_check is false, the call operator does not check that letters are valid indices into the weights vector. Use the constructor with should_check set to true (checks) to enable argument checking in the call operator.Static Public Attributes | |
| static constexpr bool | checks = true |
| Constant to enable validity checks. | |
| static constexpr bool | no_checks = false |
| Constant to disable validity checks. | |
Public Member Functions | |
| WtShortLexCompare (std::vector< size_t > &&weights, bool should_check) | |
| Construct from weights vector rvalue reference and specify whether or not the call operator should check its arguments. | |
| 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 arguments. | |
| template<typename Thing> | |
| bool | call_no_checks (Thing const &x, Thing const &y) const |
| Call operator that does no checks. | |
| WtShortLexCompare & | init (std::vector< size_t > &&weights, bool should_check) |
| Reinitialize an existing WtShortLexCompare object. | |
| WtShortLexCompare & | init (std::vector< size_t > const &weights, bool should_check) |
| Reinitialize an existing WtShortLexCompare object. | |
| template<typename Thing> | |
| 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. | |
| bool | should_check () const noexcept |
Returns the value of the constructor parameter should_check. | |
| WtShortLexCompare & | should_check (bool val) noexcept |
Set the value of the constructor parameter should_check. | |
| std::vector< size_t > const & | weights () const noexcept |
| Returns the weights. | |
| WtShortLexCompare & | weights (std::vector< size_t > const &val) |
| Set the weights. | |
|
inline |
Constructs a comparison object that stores a copy of the provided weights vector, where the ith index corresponds to the weight of the ith letter in the alphabet. The should_check parameter determines whether the call operator will validate that letters are valid indices.
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
|
inline |
Constructs a comparison object that takes ownership of the provided weights vector, where the ith index corresponds to the weight of the ith letter in the alphabet. The should_check parameter determines whether the call operator will validate that letters are valid indices.
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
|
inlinenodiscard |
This member function always uses wt_shortlex_compare_no_checks to compare x and y, regardless of the value of the constructor parameter should_check. Use this when you want to ensure validation is not performed.
| Thing | the type of the objects to be compared. |
| x | const reference to the first object for comparison. |
| y | const reference to the second object for comparison. |
true if x is weighted short-lex less than y, and false otherwise.
|
inline |
This function reinitializes an existing WtShortLexCompare object so that it is in the same state as if it was newly constructed using the same arguments.
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
|
inline |
This function reinitializes an existing WtShortLexCompare object so that it is in the same state as if it was newly constructed using the same arguments.
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
|
inlinenodiscard |
Call operator that compares x and y using wt_shortlex_compare (if the constructor parameter should_check is true) or wt_shortlex_compare_no_checks (if should_check is false).
| Thing | the type of the objects to be compared. |
| x | const reference to the first object for comparison. |
| y | const reference to the second object for comparison. |
true if x is weighted short-lex less than y, and false otherwise.| LibsemigroupsException | if the constructor parameter should_check is true and any letter is not a valid index into the weights vector. |
should_check is false, it is not checked that the letters are valid indices into the weights vector.
|
inlinenodiscardnoexcept |
This function returns the current value of the constructor parameter should_check.
|
inlinenoexcept |
This function sets the value of should_check to val. This parameter determines whether or not the call operator is checking its arguments.
| val | the new value of should_check. |
|
inlinenodiscardnoexcept |
This function returns the current value of the weights used to define the comparison implemented by WtShortLexCompare.
|
inline |
This function can be used to redefine the weights used to define the comparison implemented by WtShortLexCompare.
| val | the new weights to use. |
|
staticconstexpr |
This constant can be used in the constructors to indicate that checks should be performed on the arguments to the call operator.
|
staticconstexpr |
This constant can be used in the constructors to indicate that no checks should be performed on the arguments to the call operator.