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.
- Warning
- When the constructor parameter
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.
- See also
-
|
| static constexpr bool | checks = true |
| | Constant to enable validity checks.
|
| |
| static constexpr bool | no_checks = false |
| | Constant to disable validity checks.
|
| |
◆ WtShortLexCompare() [1/2]
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.
- Parameters
-
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ WtShortLexCompare() [2/2]
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.
- Parameters
-
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ call_no_checks()
template<typename Thing>
| bool call_no_checks |
( |
Thing const & | x, |
|
|
Thing const & | y ) const |
|
inlinenodiscard |
◆ init() [1/2]
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.
- Parameters
-
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ init() [2/2]
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.
- Parameters
-
| weights | the weights vector. |
| should_check | if true (checks), the call operator will check validity; if false (no_checks), it will not. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ operator()()
template<typename Thing>
| bool operator() |
( |
Thing const & | x, |
|
|
Thing const & | y ) const |
|
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).
- Template Parameters
-
| Thing | the type of the objects to be compared. |
- Parameters
-
| x | const reference to the first object for comparison. |
| y | const reference to the second object for comparison. |
- Returns
- The boolean value
true if x is weighted short-lex less than y, and false otherwise.
- Exceptions
-
| LibsemigroupsException | if the constructor parameter should_check is true and any letter is not a valid index into the weights vector. |
- Complexity
- See
- Warning
- If the constructor parameter
should_check is false, it is not checked that the letters are valid indices into the weights vector.
◆ should_check() [1/2]
| bool should_check |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
This function returns the current value of the constructor parameter should_check.
- Returns
- Whether or not the call operator is checking its arguments.
- Exceptions
- This function is
noexcept and is guaranteed never to throw.
- See also
- should_check(bool)
◆ should_check() [2/2]
This function sets the value of should_check to val. This parameter determines whether or not the call operator is checking its arguments.
- Parameters
-
| val | the new value of should_check. |
- Returns
- A reference to
*this.
- Exceptions
- This function is
noexcept and is guaranteed never to throw.
- See also
- should_check()
◆ weights() [1/2]
This function returns the current value of the weights used to define the comparison implemented by WtShortLexCompare.
- Returns
- The current weights.
- Exceptions
- This function is
noexcept and is guaranteed never to throw.
◆ weights() [2/2]
This function can be used to redefine the weights used to define the comparison implemented by WtShortLexCompare.
- Parameters
-
| val | the new weights to use. |
- Returns
- A reference to
*this.
- Exceptions
- This function is
noexcept and is guaranteed never to throw.
◆ checks
This constant can be used in the constructors to indicate that checks should be performed on the arguments to the call operator.
◆ no_checks
This constant can be used in the constructors to indicate that no checks should be performed on the arguments to the call operator.
The documentation for this struct was generated from the following file:
- /Users/jdm3/libsemigroups/include/libsemigroups/order.hpp