24#ifndef MYSQL_SETS_THROWING_MAP_BOUNDARY_STORAGE_H
25#define MYSQL_SETS_THROWING_MAP_BOUNDARY_STORAGE_H
53template <
class Map_iterator_tp,
class Mutable_map_iterator_tp =
void>
56 Map_boundary_iterator<Map_iterator_tp, Mutable_map_iterator_tp>> {
75 requires(!std::same_as<Mutable_map_iterator_t, void>)
79 [[nodiscard]]
auto &
get()
const {
128 Map_boundary_iterator<std::map<int, int>::iterator>>);
153template <Is_bounded_set_traits Set_traits_tp,
class Map_tp>
156 Map_boundary_storage<Set_traits_tp, Map_tp>, Map_tp>,
158 Map_boundary_storage<Set_traits_tp, Map_tp>, Set_traits_tp,
159 detail::Map_boundary_iterator<
160 mysql::ranges::Range_iterator_type<Map_tp>>,
161 detail::Map_boundary_iterator<
162 mysql::ranges::Range_const_iterator_type<Map_tp>,
163 mysql::ranges::Range_iterator_type<Map_tp>>,
164 Iterator_get_value> {
167 template <
class Type_t>
168 static constexpr std::pair<Type_t &, Type_t &>
make_pair(Type_t &second,
170 return {first, second};
172 template <
class Type_t>
173 static constexpr std::pair<Type_t, Type_t>
make_pair(
const Type_t &second,
174 const Type_t &first) {
175 return {first, second};
196 static_assert(std::bidirectional_iterator<Iterator_t>);
203 std::same_as<std::pair<const Element_t, Element_t>,
Map_value_t>);
230 template <std::input_iterator First_iterator_t>
232 const First_iterator_t &first,
233 const std::sentinel_for<First_iterator_t>
auto &last,
264 assign(other.begin(), other.end());
269 template <std::input_iterator First_iterator_t>
270 void assign(
const First_iterator_t &first,
271 const std::sentinel_for<First_iterator_t>
auto &last) {
274 mysql::ranges::make_disjoint_pairs_iterator<Make_pair_reverse>(first),
275 mysql::ranges::make_disjoint_pairs_iterator<Make_pair_reverse>(last));
284 [[nodiscard]]
auto end()
const {
295 [[nodiscard]]
auto size()
const {
return 2 *
map().size(); }
298 [[nodiscard]]
bool empty()
const {
return map().empty(); }
301 [[nodiscard]]
explicit operator bool()
const {
return (
bool)
map(); }
304 template <mysql::meta::Is_same_ignore_const<This_t> This_arg_t>
307 auto map_position =
self.map().upper_bound(element);
308 if (map_position ==
self.
map().
end())
return self.end();
320 map_position,
le(map_position->second, element));
324 template <mysql::meta::Is_same_ignore_const<This_t> This_arg_t>
327 auto map_position =
self.map().lower_bound(element);
328 if (map_position ==
self.
map().
end())
return self.end();
330 map_position,
lt(map_position->second, element));
347 assert(
left.is_endpoint() ==
right.is_endpoint());
358 auto interval_iterator =
364 auto map_iterator =
left.map_iterator();
365 auto left_start = map_iterator->second;
366 map_iterator =
map().erase(map_iterator,
right.map_iterator());
367 map_iterator->second = left_start;
387 [
this](
const auto &map_iterator,
const auto &e1,
const auto &e2) {
388 this->
map().emplace_hint(map_iterator, e1, e2);
410 [
this, &
source](
const auto &map_iterator,
const auto &e1,
414 node_handle.key() = e1;
415 node_handle.mapped() = e2;
416 this->map().insert(map_iterator, std::move(node_handle));
431 assert(position ==
begin() ||
lt(*std::prev(position), element));
432 assert(position ==
end() || std::next(position) ==
end() ||
433 lt(element, *std::next(position)));
438 auto next_map_iterator = std::next(map_iterator);
440 auto node_handle =
map().extract(map_const_iterator);
441 node_handle.key() = element;
442 auto it =
map().insert(next_map_iterator, std::move(node_handle));
447 map_iterator->second = element;
468 const auto &inserter) {
470 assert(position ==
begin() ||
lt(*std::prev(position), v1));
472 assert(position ==
end() ||
lt(v2, *position));
477 auto &element_a = map_iterator->second;
478 inserter(map_iterator, v1, element_a);
483 inserter(map_iterator, v2, v1);
Allocator using a Memory_resource to do the allocation.
Definition: allocator.h:52
Polymorphism-free memory resource class with custom allocator and deallocator functions.
Definition: memory_resource.h:88
CRTP base class (mixin) to define a wrapper around a container.
Definition: basic_container_wrapper.h:59
auto get_memory_resource() const noexcept
Return the memory resource used by the wrapped object.
Definition: basic_container_wrapper.h:137
auto & wrapped() &noexcept
Definition: basic_container_wrapper.h:183
CRTP base class (mixin) that makes your class a standard-compliant iterator, given only a minimal set...
Definition: iterator_interface.h:370
CRTP base class (mixin) to define a set that has upper_bound and lower_bound members.
Definition: upper_lower_bound_interface.h:193
Storage for boundary points, backed by a std::map.
Definition: map_boundary_storage.h:164
Map_boundary_storage(const Is_readable_boundary_storage_over_traits< Set_traits_t > auto &source, const Memory_resource_t &memory_resource)
Constructor copying from another type, using the given Memory_resource.
Definition: map_boundary_storage.h:216
auto end() const
Definition: map_boundary_storage.h:284
Map_boundary_storage & operator=(const Map_boundary_storage &other)=default
static auto upper_bound_impl(This_arg_t &self, const Element_t &element)
Definition: map_boundary_storage.h:305
Map_boundary_storage & operator=(const Is_boundary_storage_over_traits< Set_traits_t > auto &source)
Assignment operator copying from another type, preserving the existing Memory_resource.
Definition: map_boundary_storage.h:252
void assign(const Is_readable_boundary_storage_over_traits< Set_traits_t > auto &other)
Assign from another type, preserving the existing Memory_resource.
Definition: map_boundary_storage.h:262
Map_boundary_storage & operator=(Map_boundary_storage &&other) noexcept=default
const Map_t & map() const
Definition: map_boundary_storage.h:259
detail::Map_boundary_iterator< Map_const_iterator_t, Map_iterator_t > Const_iterator_t
Definition: map_boundary_storage.h:200
Map_boundary_storage(const First_iterator_t &first, const std::sentinel_for< First_iterator_t > auto &last, const Memory_resource_t &memory_resource=Memory_resource_t())
Constructor copying a range defined by the given iterators, using memory_resource if given,...
Definition: map_boundary_storage.h:231
Map_boundary_storage(const Is_readable_boundary_storage_over_traits< Set_traits_t > auto &source)
Constructor copying both values and Memory_resource from another storage.
Definition: map_boundary_storage.h:223
Set_traits_tp Set_traits_t
Definition: map_boundary_storage.h:182
static constexpr bool lt(const Element_t &left, const Element_t &right)
Return true if "left < right", according to the order defined by Set_traits_t.
Definition: map_boundary_storage.h:490
~Map_boundary_storage()=default
static constexpr bool le(const Element_t &left, const Element_t &right)
Return true if "left <= right", according to the order defined by Set_traits_t.
Definition: map_boundary_storage.h:497
detail::Map_boundary_iterator< Map_iterator_t > Iterator_t
Definition: map_boundary_storage.h:195
Map_boundary_storage(const Map_boundary_storage &other)=default
mysql::ranges::Range_value_type< Map_t > Map_value_t
Definition: map_boundary_storage.h:188
bool empty() const
Definition: map_boundary_storage.h:298
Map_boundary_storage(Map_boundary_storage &&other) noexcept=default
auto size() const
Definition: map_boundary_storage.h:295
mysql::ranges::Range_iterator_type< Map_t > Map_iterator_t
Definition: map_boundary_storage.h:193
mysql::ranges::Range_const_iterator_type< Map_t > Map_const_iterator_t
Definition: map_boundary_storage.h:194
auto begin() const
Definition: map_boundary_storage.h:279
Map_t & map()
Definition: map_boundary_storage.h:258
Map_tp Map_t
Definition: map_boundary_storage.h:183
Map_boundary_storage(const Memory_resource_t &memory_resource=Memory_resource_t()) noexcept
Construct a new, empty object, with the given Memory_resource.
Definition: map_boundary_storage.h:209
auto begin()
Definition: map_boundary_storage.h:289
Iterator_t update_point(const Iterator_t &position, const Element_t &element)
Modify the boundary that the iterator points to.
Definition: map_boundary_storage.h:429
mysql::allocators::Memory_resource Memory_resource_t
Definition: map_boundary_storage.h:190
auto end()
Definition: map_boundary_storage.h:292
static auto lower_bound_impl(This_arg_t &self, const Element_t &element)
Definition: map_boundary_storage.h:325
void assign(const First_iterator_t &first, const std::sentinel_for< First_iterator_t > auto &last)
Assign from the range defined by the given iterators, preserving the existing Memory_resource.
Definition: map_boundary_storage.h:270
static constexpr bool has_fast_insertion
Declare that insertion is "fast", i.e., O(log(N)).
Definition: map_boundary_storage.h:206
Iterator_t erase(const Iterator_t &left, const Iterator_t &right)
Erase an even-length range of boundary points.
Definition: map_boundary_storage.h:345
Iterator_t insert(const Iterator_t &position, const Element_t &v1, const Element_t &v2)
Insert two boundary points by allocating a new element.
Definition: map_boundary_storage.h:383
typename Set_traits_t::Element_t Element_t
Definition: map_boundary_storage.h:187
Iterator_t steal_and_insert(const Iterator_t &position, const Element_t &v1, const Element_t &v2, This_t &source) noexcept
Insert two boundary points, stealing the first element from given source object (which must be nonemp...
Definition: map_boundary_storage.h:405
Iterator_t do_insert(const Iterator_t &position, const Element_t &v1, const Element_t &v2, const auto &inserter)
Insert two boundary points.
Definition: map_boundary_storage.h:466
Boundary_iterator based on a std::map iterator or const iterator.
Definition: map_boundary_storage.h:56
Map_iterator_tp Map_iterator_t
Definition: map_boundary_storage.h:57
constexpr Map_boundary_iterator(const Map_iterator_t &position, bool is_endpoint)
Construct an iterator at the given position, and at the given endpoint state.
Definition: map_boundary_storage.h:67
constexpr Map_boundary_iterator()=default
Default constructor.
constexpr bool is_equal(const Map_boundary_iterator &other) const
Definition: map_boundary_storage.h:108
bool m_is_endpoint
Definition: map_boundary_storage.h:124
constexpr void next()
Move forward one step.
Definition: map_boundary_storage.h:96
Mutable_map_iterator_tp Mutable_map_iterator_t
Definition: map_boundary_storage.h:58
auto & get() const
Definition: map_boundary_storage.h:79
constexpr bool is_endpoint() const
Definition: map_boundary_storage.h:115
constexpr Map_boundary_iterator(const Map_boundary_iterator< Mutable_map_iterator_t > &other)
Converting constructor from the mutable iterator type, enabled if this is a const iterator.
Definition: map_boundary_storage.h:73
Map_iterator_t m_position
Definition: map_boundary_storage.h:123
constexpr const Map_iterator_t & map_iterator() const
Definition: map_boundary_storage.h:118
constexpr void prev()
Move backward one step.
Definition: map_boundary_storage.h:102
True if the iterator is declared to meet LegacyBidirectionalIterator requirements.
Definition: meta.h:83
True if Test is a boundary point iterator and a bidirectional iterator.
Definition: boundary_set_meta.h:105
True if Test is a boundary storage over the given Set traits.
Definition: boundary_set_meta.h:350
True if Test is a readable boundary storage, i.e., an object that can be used as the back-end storage...
Definition: boundary_set_meta.h:342
True if Test is a boundary storage over the given Set traits.
Definition: boundary_set_meta.h:313
Allocator class that uses a polymorphic Memory_resource to allocate memory.
Class that wraps resources in a polymorphic manner.
Header for compiler-dependent features.
#define MY_COMPILER_GCC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:242
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
bool distance(const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, double *distance, bool *is_null) noexcept
Computes the distance between two geometries.
Definition: distance.cc:40
void right(std::string *to_trim)
Definition: trim.h:41
void left(std::string *to_trim)
Definition: trim.h:35
void map_or_set_assign(Map_or_set_t &map_or_set, const Source_iterator_t &first, const std::sentinel_for< Source_iterator_t > auto &last)
Replace the contents of container with that of the range given by the two iterators,...
Definition: map_or_set_assign.h:107
std::remove_cvref_t< decltype(std::declval< const Range_t >().begin())> Range_const_iterator_type
Gives the const_iterator type, deduced from the begin() const member.
Definition: meta.h:47
auto make_disjoint_pairs_iterator(const Iterator_t &position)
Factory function to create a Disjoint_pairs_iterator.
Definition: disjoint_pairs.h:181
std::remove_cvref_t< decltype(std::declval< Range_t >().begin())> Range_iterator_type
Gives the iterator type, deduced from the begin() member.
Definition: meta.h:42
Iterator_value_type< Range_iterator_type< Range_t > > Range_value_type
Gives the value type for any collection, deduced from *begin().
Definition: meta.h:67
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
Definition: instrumented_condition_variable.h:32
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Definition: map_boundary_storage.h:166
static constexpr std::pair< Type_t &, Type_t & > make_pair(Type_t &second, Type_t &first)
Definition: map_boundary_storage.h:168
static constexpr std::pair< Type_t, Type_t > make_pair(const Type_t &second, const Type_t &first)
Definition: map_boundary_storage.h:173