Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-concepts.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
54# ifndef AH_CONCEPTS_H
55# define AH_CONCEPTS_H
56
57# include <concepts>
58# include <type_traits>
59
60namespace Aleph
61{
66 template <typename F, typename T>
68 requires(const F & f, const T & a, const T & b)
69 {
70 { f(a, b) } -> std::convertible_to<bool>;
71 };
72
83 template <typename F, typename T>
84 concept StrictWeakOrder = std::strict_weak_order<F, T, T>;
85
96 template <typename F, typename T>
97 concept EqualityComparator = std::equivalence_relation<F, T, T>;
98
115 template <typename T, typename Key>
116 concept BSTPolicy =
117 requires { typename T::Node; } &&
118 requires(T & t, T & t2, const T & ct,
119 typename T::Node * p, const Key & key)
120 {
121 { t.getRoot() } -> std::convertible_to<typename T::Node *>;
122 { t.search(key) } -> std::convertible_to<typename T::Node *>;
123 { t.search_or_insert(p) } -> std::convertible_to<typename T::Node *>;
124 { t.insert_dup(p) } -> std::convertible_to<typename T::Node *>;
125 { t.remove(key) } -> std::convertible_to<typename T::Node *>;
126 { ct.verify() } -> std::convertible_to<bool>;
127 { t.swap(t2) };
128 { t.get_compare() };
129 requires (!requires { ct.getRoot(); } ||
130 requires
131 {
132 { ct.getRoot() } -> std::convertible_to<const typename T::Node *>;
133 });
134 requires (!requires { ct.search(key); } ||
135 requires
136 {
137 { ct.search(key) } -> std::convertible_to<const typename T::Node *>;
138 });
139 };
140
150 template <typename T>
151 concept AlephArrayConvertible = requires(T c)
152 {
153 typename T::Item_Type;
154 { c.get_it() };
155 };
156
185 template <typename C>
187 requires { typename C::Item_Type; } and
188 requires(C & c, const C & cc, const typename C::Item_Type & val)
189 {
190 { cc.size() } -> std::convertible_to<size_t>;
191 { cc.is_empty() } -> std::convertible_to<bool>;
192 c.append(val);
193 } and
194 // mutable_for_each must accept a void(Item_Type&) callable
195 requires(C & c)
196 {
197 c.mutable_for_each([](typename C::Item_Type &) {});
198 };
199
221 template <typename C>
224 requires(const C & cc)
225 {
226 cc.get_it();
227 };
228
234 template <typename T>
236 std::is_integral_v<std::remove_cv_t<T>> and
237 not std::is_same_v<std::remove_cv_t<T>, bool>;
238
239} // namespace Aleph
240
241# endif // AH_CONCEPTS_H
Concept that identifies types that can be converted or used as an Aleph Array.
Concept for Aleph-w mutable sequential containers.
Concept for Aleph-w sequential containers that can be iterated.
Concept for BST tree policies used by DynSetTree.
A callable that takes two const T& and returns bool.
Definition ah-concepts.H:67
Equivalence relation constraint for equality comparators.
Definition ah-concepts.H:97
Integral value accepted by linear-time integer sorting algorithms.
Strict weak ordering constraint for BST comparators.
Definition ah-concepts.H:84
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
and
Check uniqueness with explicit hash + equality functors.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::decay_t< typename HeadC::Item_Type > T
Definition ah-zip.H:105