23#ifndef LIBSEMIGROUPS_IS_TRANSF_HPP_
24#define LIBSEMIGROUPS_IS_TRANSF_HPP_
32#include <unordered_map>
35#include "constants.hpp"
37#include "detail/print.hpp"
38#include "detail/stl.hpp"
48 template <
typename Iterator>
49 std::pair<Iterator, size_t> find_duplicates(
52 std::unordered_map<std::decay_t<
decltype(*first)>,
size_t>& seen);
54 template <
typename Iterator>
55 [[nodiscard]] std::pair<Iterator, size_t> find_duplicates(Iterator first,
57 std::unordered_map<std::decay_t<
decltype(*first)>,
size_t> seen;
58 return find_duplicates(first, last, seen);
61 template <
typename Iterator>
62 [[nodiscard]]
bool has_duplicates(Iterator first, Iterator last) {
63 return find_duplicates(first, last).first != last;
66 template <
typename Iterator>
67 void throw_if_duplicates(
70 std::unordered_map<std::decay_t<
decltype(*first)>,
size_t>& seen,
71 std::string_view where);
73 template <
typename Iterator>
74 void throw_if_duplicates(Iterator first,
76 std::string_view where) {
77 std::unordered_map<std::decay_t<
decltype(*first)>,
size_t> seen;
78 throw_if_duplicates(first, last, seen, where);
83 template <
typename Po
int>
86 template <
typename Po
int>
87 bool is_valid_degree(
size_t deg) {
88 return deg <= max_degree<Point>();
91 template <
typename Po
int>
92 void throw_if_degree_too_large(
size_t deg);
94 template <
typename Iterator,
typename Func>
95 void throw_if_value_out_of_range(Iterator first,
98 std::string_view where);
100 template <
typename Iterator>
101 void throw_if_not_ptransf(Iterator first, Iterator last,
size_t deg);
103 template <
typename Iterator>
104 void throw_if_not_ptransf(Iterator first, Iterator last) {
105 throw_if_not_ptransf(first, last,
std::distance(first, last));
108 template <
typename Iterator>
109 void throw_if_not_ptransf(Iterator dom_first,
115 template <
typename Iterator>
116 void throw_if_not_transf(Iterator first, Iterator last,
size_t deg);
118 template <
typename Iterator>
119 void throw_if_not_transf(Iterator first, Iterator last) {
120 throw_if_not_transf(first, last,
std::distance(first, last));
123 template <
typename Iterator>
124 void throw_if_not_perm(Iterator first, Iterator last,
size_t deg) {
125 throw_if_not_transf(first, last, deg);
126 throw_if_duplicates(first, last,
"image");
129 template <
typename Iterator>
130 void throw_if_not_perm(Iterator first, Iterator last) {
134 template <
typename Iterator>
135 void throw_if_not_pperm(Iterator first, Iterator last,
size_t deg) {
136 throw_if_not_ptransf(first, last, deg);
137 throw_if_duplicates(first, last,
"image");
140 template <
typename Iterator>
141 void throw_if_not_pperm(Iterator first, Iterator last) {
142 throw_if_not_ptransf(first, last);
143 throw_if_duplicates(first, last,
"image");
146 template <
typename Iterator>
147 void throw_if_not_pperm(Iterator dom_first,
152 throw_if_not_ptransf(dom_first, dom_last, img_first, img_last, deg);
153 throw_if_duplicates(img_first, img_last,
"image");
186 template <
typename Iterator>
187 [[nodiscard]]
bool is_ptransf(Iterator first, Iterator last,
size_t deg) {
189 std::is_unsigned_v<std::decay_t<decltype(*std::declval<Iterator>())>>);
219 template <
typename Iterator>
220 [[nodiscard]]
bool is_ptransf(Iterator first, Iterator last) {
249 template <
typename Iterator>
250 [[nodiscard]]
bool is_transf(Iterator first, Iterator last,
size_t deg) {
252 std::is_unsigned_v<std::decay_t<decltype(*std::declval<Iterator>())>>);
253 return std::none_of(first, last, [°](
auto val) {
return val >= deg; });
279 template <
typename Iterator>
280 [[nodiscard]]
bool is_transf(Iterator first, Iterator last) {
312 template <
typename Iterator>
313 [[nodiscard]]
bool is_pperm(Iterator first, Iterator last,
size_t deg) {
314 return is_ptransf(first, last, deg) && !detail::has_duplicates(first, last);
343 template <
typename Iterator>
344 [[nodiscard]]
bool is_pperm(Iterator first, Iterator last) {
372 template <
typename Iterator>
373 [[nodiscard]]
bool is_perm(Iterator first, Iterator last,
size_t deg) {
374 return is_transf(first, last, deg) && !detail::has_duplicates(first, last);
401 template <
typename Iterator>
402 [[nodiscard]]
bool is_perm(Iterator first, Iterator last) {
407#include "is-transf.tpp"
Undefined const UNDEFINED
Value for something undefined.
bool is_ptransf(Iterator first, Iterator last, size_t deg)
Returns whether or not the argument describes a partial transformation.
Definition is-transf.hpp:187
bool is_transf(Iterator first, Iterator last, size_t deg)
Returns whether or not the argument describes a transformation.
Definition is-transf.hpp:250
bool is_pperm(Iterator first, Iterator last, size_t deg)
Returns whether or not the argument describes a partial permutation.
Definition is-transf.hpp:313
bool is_perm(Iterator first, Iterator last, size_t deg)
Returns whether or not the argument describes a permutation.
Definition is-transf.hpp:373
Namespace for everything in the libsemigroups library.
Definition action.hpp:44