24#ifndef MYSQL_SETS_MAP_NESTED_STORAGE_H
25#define MYSQL_SETS_MAP_NESTED_STORAGE_H
57template <Is_nested_set_traits Set_traits_tp,
class Map_tp>
60 Map_nested_storage<Set_traits_tp, Map_tp>, Map_tp>,
62 Map_nested_storage<Set_traits_tp, Map_tp>,
63 typename Set_traits_tp::Key_traits_t,
64 mysql::ranges::Range_iterator_type<Map_tp>,
65 mysql::ranges::Range_const_iterator_type<Map_tp>,
75 using Key_t =
typename Key_traits_t::Element_t;
82 static_assert(std::bidirectional_iterator<Iterator_t>);
90 static_assert(std::same_as<Key_t, mysql::ranges::Map_key_type<Map_t>>);
93 Map_t>::Set_category_t>);
94 static_assert(std::same_as<
98 static_assert(std::same_as<Value_t, std::pair<const Key_t, Mapped_t>>);
121 template <
class Iterator_t>
126 for (
auto input = it1; input != it2; ++input) {
127 auto opt_output = this->
emplace(input->first);
129 auto &output_mapped = opt_output.value()->second;
130 auto ret = output_mapped.assign(input->second);
133 return Return_status::ok;
145 auto ret =
map().find(
key);
152 auto ret =
map().find(
key);
169 template <
class Iter>
170 [[nodiscard]]
static Iter
do_find(
auto &the_map, Iter &cursor,
172 assert(cursor == the_map.begin() ||
173 Key_traits_t::lt(std::ranges::prev(cursor)->first,
key));
175 if (cursor != the_map.end()) {
183 if (order < 0)
return the_map.end();
188 cursor = the_map.lower_bound(
key);
189 if (cursor == the_map.end()) {
191 return the_map.end();
193 if (cursor->first ==
key) {
200 return the_map.end();
252 auto ret = mysql::utils::call_and_catch([&] {
255 if (ret.has_value()) cursor = std::next(ret.value());
268 return mysql::utils::call_and_catch([&] {
288 assert(steal_element !=
source.end());
289 auto node =
source.map().extract(steal_element);
290 return map().insert(position, std::move(node));
302 return map().erase(first, last);
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
void clear() noexcept
Clear the wrapped object.
Definition: basic_container_wrapper.h:128
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
Storage for nested sets, backed by a std::map.
Definition: map_nested_storage.h:66
Map_nested_storage(const Memory_resource_t &memory_resource=Memory_resource_t{}) noexcept
Definition: map_nested_storage.h:100
Iterator_t steal_and_insert(const Iterator_t &position, This_t &source, Iterator_t steal_element) noexcept
If no entry with the given key exists, insert one and default-construct the mapped object.
Definition: map_nested_storage.h:285
Set_traits_tp Set_traits_t
Definition: map_nested_storage.h:68
typename Set_traits_t::Mapped_category_t Mapped_category_t
Definition: map_nested_storage.h:77
Const_iterator_t find(Const_iterator_t &cursor, const Key_t &key) const noexcept
Definition: map_nested_storage.h:234
typename Key_traits_t::Element_t Key_t
Definition: map_nested_storage.h:75
const auto & map() const noexcept
Definition: map_nested_storage.h:140
auto emplace(const Key_t &key) noexcept
If no entry with the given key exists, insert one and default-construct the mapped object.
Definition: map_nested_storage.h:267
Iterator_t erase(const Iterator_t &iterator)
Remove the element that the iterator points to.
Definition: map_nested_storage.h:296
auto assign(const Iterator_t &it1, const Iterator_t &it2) noexcept
Definition: map_nested_storage.h:116
auto & map() noexcept
Definition: map_nested_storage.h:137
mysql::ranges::Range_const_iterator_type< Map_t > Const_iterator_t
Definition: map_nested_storage.h:85
Const_iterator_t find(const Key_t &key) const noexcept
Definition: map_nested_storage.h:151
Map_tp Map_t
Definition: map_nested_storage.h:69
Iterator_t find(Iterator_t &cursor, const Key_t &key) noexcept
Definition: map_nested_storage.h:217
mysql::allocators::Allocator< Value_t > Allocator_t
Definition: map_nested_storage.h:88
mysql::ranges::Range_value_type< Map_t > Value_t
Definition: map_nested_storage.h:79
mysql::containers::Basic_container_wrapper< This_t, Map_t > Basic_container_wrapper_t
Definition: map_nested_storage.h:72
static Iter do_find(auto &the_map, Iter &cursor, const Key_t &key) noexcept
Common implementation of the const and non-const versions of find(cursor, key).
Definition: map_nested_storage.h:170
Iterator_t erase(const Iterator_t &first, const Iterator_t &last)
Remove the range of elements from first, inclusive, to last, exclusive.
Definition: map_nested_storage.h:301
typename Set_traits_t::Mapped_traits_t Mapped_traits_t
Definition: map_nested_storage.h:76
typename Set_traits_t::Key_traits_t Key_traits_t
Definition: map_nested_storage.h:74
mysql::ranges::Range_iterator_type< Map_t > Iterator_t
Definition: map_nested_storage.h:81
Map_nested_storage(const This_t &)=delete
Iterator_t find(const Key_t &key) noexcept
Definition: map_nested_storage.h:144
auto assign(const Iterator_t &it1, const Iterator_t &it2) noexcept
Definition: map_nested_storage.h:122
Map_nested_storage(This_t &&) noexcept=default
auto emplace(Iterator_t &cursor, const Key_t &key) noexcept
If no entry with the given key exists, insert one using the given cursor hint, and default-construct ...
Definition: map_nested_storage.h:251
mysql::ranges::Map_mapped_type< Map_t > Mapped_t
Definition: map_nested_storage.h:80
CRTP base class (mixin) to define a set that has upper_bound and lower_bound members.
Definition: upper_lower_bound_interface.h:193
True if the iterator is declared to meet LegacyBidirectionalIterator requirements.
Definition: meta.h:83
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1064
Allocator class that uses a polymorphic Memory_resource to allocate memory.
Class that wraps resources in a polymorphic manner.
void error(const char *format,...)
auto map_or_set_assign(auto &map_or_set, const Source_iterator_t &first, const std::sentinel_for< Source_iterator_t > auto &last) noexcept
Replace the contents of container with that of the range given by the two iterators,...
Definition: map_or_set_assign.h:154
std::remove_cvref_t< decltype(std::declval< Map_t >().begin() ->second)> Map_mapped_type
Gives the mapped type for any collection, deduced from begin()->first.
Definition: meta.h:88
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
std::remove_cvref_t< decltype(*std::declval< Iterator_t >())> Iterator_value_type
Gives the value type for any iterator type, deduced from operator *.
Definition: meta.h:63
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
Definition: gtid_set.h:183
Return_status
Simple, strongly-typed enumeration to indicate internal status: ok, error.
Definition: return_status.h:40
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
Define std::hash<Gtid>.
Definition: gtid.h:355
required string key
Definition: replication_asynchronous_connection_failover.proto:60
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42