MySQL 9.6.0
Source Code Documentation
mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp > Class Template Reference

Storage for nested sets, backed by a std::map. More...

#include <map_nested_storage.h>

Inheritance diagram for mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >:
[legend]

Public Types

using Set_traits_t = Set_traits_tp
 
using Map_t = Map_tp
 
using This_t = Map_nested_storage< Set_traits_t, Map_t >
 
using Basic_container_wrapper_t = mysql::containers::Basic_container_wrapper< This_t, Map_t >
 
using Key_traits_t = typename Set_traits_t::Key_traits_t
 
using Key_t = typename Key_traits_t::Element_t
 
using Mapped_traits_t = typename Set_traits_t::Mapped_traits_t
 
using Mapped_category_t = typename Set_traits_t::Mapped_category_t
 
using Value_t = mysql::ranges::Range_value_type< Map_t >
 
using Mapped_t = mysql::ranges::Map_mapped_type< Map_t >
 
using Iterator_t = mysql::ranges::Range_iterator_type< Map_t >
 
using Const_iterator_t = mysql::ranges::Range_const_iterator_type< Map_t >
 
using Memory_resource_t = mysql::allocators::Memory_resource
 
using Allocator_t = mysql::allocators::Allocator< Value_t >
 
- Public Types inherited from mysql::containers::Basic_container_wrapper< Map_nested_storage< Set_traits_tp, Map_tp >, Map_tp >
using Wrapped_t = Map_tp
 
- Public Types inherited from mysql::sets::Upper_lower_bound_interface< Map_nested_storage< Set_traits_tp, Map_tp >, Set_traits_tp::Key_traits_t, mysql::ranges::Range_iterator_type< Map_tp >, mysql::ranges::Range_const_iterator_type< Map_tp >, Iterator_get_first >
using Iterator_t = Iterator_tp
 
using Const_iterator_t = Const_iterator_tp
 
using Set_traits_t = Set_traits_tp
 
using Iterator_getter_t = Iterator_getter_tp
 
using Element_t = typename Set_traits_t::Element_t
 

Public Member Functions

 Map_nested_storage (const Memory_resource_t &memory_resource=Memory_resource_t{}) noexcept
 
 Map_nested_storage (const This_t &)=delete
 
 Map_nested_storage (This_t &&) noexcept=default
 
This_toperator= (const This_t &)=delete
 
This_toperator= (This_t &&) noexcept=default
 
 ~Map_nested_storage ()=default
 
template<class Iterator_t >
requires std::same_as<mysql::ranges::Iterator_value_type<Iterator_t>, Mapped_t>
auto assign (const Iterator_t &it1, const Iterator_t &it2) noexcept
 
template<class Iterator_t >
auto assign (const Iterator_t &it1, const Iterator_t &it2) noexcept
 
auto & map () noexcept
 
const auto & map () const noexcept
 
Iterator_t find (const Key_t &key) noexcept
 
Const_iterator_t find (const Key_t &key) const noexcept
 
Iterator_t find (Iterator_t &cursor, const Key_t &key) noexcept
 
Const_iterator_t find (Const_iterator_t &cursor, const Key_t &key) const noexcept
 
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 the mapped object. More...
 
auto emplace (const Key_t &key) noexcept
 If no entry with the given key exists, insert one and default-construct the mapped object. More...
 
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. More...
 
Iterator_t erase (const Iterator_t &iterator)
 Remove the element that the iterator points to. More...
 
Iterator_t erase (const Iterator_t &first, const Iterator_t &last)
 Remove the range of elements from first, inclusive, to last, exclusive. More...
 
template<std::input_iterator First_iterator_t, std::sentinel_for< First_iterator_t > Sentinel_t>
requires requires(Wrapped_t w, First_iterator_t f, Sentinel_t s) { w.assign(f, s); }
auto assign (const First_iterator_t &first, const Sentinel_t &last) noexcept(shall_catch==mysql::utils::Shall_catch::yes||noexcept(std::declval< Wrapped_t >().assign(first, last)))
 Assign a range defined by the two iterators to the wrapped object. More...
 
template<class Other_t >
auto assign (const Other_t &other) noexcept(shall_catch==mysql::utils::Shall_catch::yes||noexcept(std::declval< Self_t >().assign(other.begin(), other.end())))
 Copy-assign the other object to the wrapped object. More...
 
void assign (Self_t &&other) noexcept
 Move-assign the other object to the wrapped object. More...
 
- Public Member Functions inherited from mysql::containers::Basic_container_wrapper< Map_nested_storage< Set_traits_tp, Map_tp >, Map_tp >
 Basic_container_wrapper (Args_t &&...args) noexcept(noexcept(Wrapped_t(std::forward< Args_t >(args)...)))
 Constructor that delegates all parameters to the constructor of the wrapped class. More...
 
auto assign (const First_iterator_t &first, const Sentinel_t &last) noexcept(mysql::utils::Shall_catch::no==mysql::utils::Shall_catch::yes||noexcept(std::declval< Wrapped_t >().assign(first, last)))
 Assign a range defined by the two iterators to the wrapped object. More...
 
auto assign (const Other_t &other) noexcept(mysql::utils::Shall_catch::no==mysql::utils::Shall_catch::yes||noexcept(std::declval< Self_t >().assign(other.begin(), other.end())))
 Copy-assign the other object to the wrapped object. More...
 
void assign (Self_t &&other) noexcept
 Move-assign the other object to the wrapped object. More...
 
void clear () noexcept
 Clear the wrapped object. More...
 
auto get_memory_resource () const noexcept
 Return the memory resource used by the wrapped object. More...
 
auto get_allocator () const noexcept
 Return the allocator used by the wrapped object. More...
 
auto begin () noexcept
 
auto begin () const noexcept
 
auto end () noexcept
 
auto end () const noexcept
 
auto empty () const noexcept
 
auto size () const noexcept
 
- Public Member Functions inherited from mysql::ranges::Collection_interface< Self_tp >
constexpr auto cbegin () const
 Return constant iterator to the beginning. More...
 
constexpr auto cend () const
 Return constant iterator to the end. More...
 
constexpr auto rbegin ()
 Return reverse iterator to the beginning. More...
 
constexpr auto rend ()
 Return reverse iterator to the end. More...
 
constexpr auto rbegin () const
 Return const reverse iterator to the beginning. More...
 
constexpr auto rend () const
 Return const reverse iterator to the end. More...
 
constexpr auto crbegin () const
 Return const reverse iterator to the beginning. More...
 
constexpr auto crend () const
 Return const reverse iterator to the end. More...
 
constexpr bool empty () const
 Return true if the range is empty, i.e., begin() == end(). More...
 
constexpr operator bool () const
 Return true if the range is non-empty, i.e., begin() != end(). More...
 
constexpr bool operator! () const
 Return true if the range is empty, i.e., begin() == end(). More...
 
constexpr auto size () const
 Return the number of elements in this view, unsigned (size_t), by computing std::ranges::distance(begin, end) More...
 
constexpr auto ssize () const
 Return the number of elements in this view, signed (ptrdiff_t). More...
 
constexpr decltype(auto) front () const
 Return the first element. More...
 
constexpr decltype(auto) back () const
 Return the last element. Enabled if we have bidirectional iterators. More...
 
constexpr decltype(auto) operator[] (std::ptrdiff_t n)
 Return the n'th element, possibly mutable. More...
 
constexpr decltype(auto) operator[] (std::ptrdiff_t n) const
 Return the n'th element, const. More...
 
constexpr auto * data ()
 Return pointer to underlying contiguous memory. More...
 
constexpr auto * data () const
 Return const pointer to underlying contiguous memory. More...
 
- Public Member Functions inherited from mysql::sets::Upper_lower_bound_interface< Map_nested_storage< Set_traits_tp, Map_tp >, Set_traits_tp::Key_traits_t, mysql::ranges::Range_iterator_type< Map_tp >, mysql::ranges::Range_const_iterator_type< Map_tp >, Iterator_get_first >
constexpr Iterator_t lower_bound (const Iterator_t &hint, const Element_t &element)
 Return the lower bound for element, using an iterator hint known to be less than or equal to the correct result. More...
 
constexpr Const_iterator_t lower_bound (const Const_iterator_t &hint, const Element_t &element) const
 Return the lower bound for element, using an iterator hint known to be less than or equal to the correct result. More...
 
constexpr Iterator_t lower_bound (const Element_t &element)
 Return the lower bound for element. More...
 
constexpr Const_iterator_t lower_bound (const Element_t &element) const
 Return the lower bound for element. More...
 
constexpr Iterator_t upper_bound (const Iterator_t &hint, const Element_t &element)
 Return the upper bound for element, using an iterator hint known to be less than or equal to the correct result. More...
 
constexpr Const_iterator_t upper_bound (const Const_iterator_t &hint, const Element_t &element) const
 Return the upper bound for element, using an iterator hint known to be less than or equal to the correct result. More...
 
constexpr Iterator_t upper_bound (const Element_t &element)
 Return the upper bound for element. More...
 
constexpr Const_iterator_t upper_bound (const Element_t &element) const
 Return the upper bound for element. More...
 

Static Private Member Functions

template<class Iter >
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). More...
 

Additional Inherited Members

- Static Public Member Functions inherited from mysql::sets::Upper_lower_bound_interface< Map_nested_storage< Set_traits_tp, Map_tp >, Set_traits_tp::Key_traits_t, mysql::ranges::Range_iterator_type< Map_tp >, mysql::ranges::Range_const_iterator_type< Map_tp >, Iterator_get_first >
static constexpr Iter_t lower_bound_dispatch (Self_arg_t &self_arg, const Iter_t &hint, const Element_t &element)
 Implements the lower_bound functions with hint defined above, checking if the hint is already the correct answer, and otherwise delegating to the implementing class. More...
 
static constexpr auto lower_bound_dispatch (Self_arg_t &self_arg, const Element_t &element)
 Implements the lower_bound functions without hint defined above. More...
 
static constexpr Iter_t upper_bound_dispatch (Self_arg_t &self_arg, const Iter_t &hint, const Element_t &element)
 Implements the upper_bound functions with hint defined above, checking if the hint is already the correct answer, and otherwise delegating to the implementing class. More...
 
static constexpr auto upper_bound_dispatch (Self_arg_t &self_arg, const Element_t &element)
 Implements the upper_bound functions without hint defined above. More...
 
- Protected Member Functions inherited from mysql::containers::Basic_container_wrapper< Map_nested_storage< Set_traits_tp, Map_tp >, Map_tp >
auto & wrapped () &noexcept
 
const auto & wrapped () const &noexcept
 
auto && wrapped () &&noexcept
 

Detailed Description

template<Is_nested_set_traits Set_traits_tp, class Map_tp>
class mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >

Storage for nested sets, backed by a std::map.

Template Parameters
Set_traits_tpNested set traits.
Map_tpType of map. This should have an API similar to std::map, with key type equal to Set_traits_tp::Key_traits_t::Element_t and value type a Set with category Set_traits_tp::Mapped_category_t and traits Set_traits_tp::Mapped_traits_t.

Member Typedef Documentation

◆ Allocator_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Allocator_t = mysql::allocators::Allocator<Value_t>

◆ Basic_container_wrapper_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Basic_container_wrapper_t = mysql::containers::Basic_container_wrapper<This_t, Map_t>

◆ Const_iterator_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Const_iterator_t = mysql::ranges::Range_const_iterator_type<Map_t>

◆ Iterator_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Iterator_t = mysql::ranges::Range_iterator_type<Map_t>

◆ Key_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Key_t = typename Key_traits_t::Element_t

◆ Key_traits_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Key_traits_t = typename Set_traits_t::Key_traits_t

◆ Map_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Map_t = Map_tp

◆ Mapped_category_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Mapped_category_t = typename Set_traits_t::Mapped_category_t

◆ Mapped_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Mapped_t = mysql::ranges::Map_mapped_type<Map_t>

◆ Mapped_traits_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Mapped_traits_t = typename Set_traits_t::Mapped_traits_t

◆ Memory_resource_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Memory_resource_t = mysql::allocators::Memory_resource

◆ Set_traits_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Set_traits_t = Set_traits_tp

◆ This_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::This_t = Map_nested_storage<Set_traits_t, Map_t>

◆ Value_t

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
using mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Value_t = mysql::ranges::Range_value_type<Map_t>

Constructor & Destructor Documentation

◆ Map_nested_storage() [1/3]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Map_nested_storage ( const Memory_resource_t memory_resource = Memory_resource_t{})
inlineexplicitnoexcept

◆ Map_nested_storage() [2/3]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Map_nested_storage ( const This_t )
delete

◆ Map_nested_storage() [3/3]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::Map_nested_storage ( This_t &&  )
defaultnoexcept

◆ ~Map_nested_storage()

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::~Map_nested_storage ( )
default

Member Function Documentation

◆ assign() [1/5]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
template<std::input_iterator First_iterator_t, std::sentinel_for< First_iterator_t > Sentinel_t>
requires requires(Wrapped_t w, First_iterator_t f, Sentinel_t s) { w.assign(f, s); }
auto mysql::containers::Basic_container_wrapper< Self_tp, Wrapped_tp, shall_catch >::assign ( const First_iterator_t &  first,
const Sentinel_t &  last 
)
inlinenoexcept

Assign a range defined by the two iterators to the wrapped object.

This is enabled provided that the wrapped class defines an assign member taking two iterators.

◆ assign() [2/5]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
template<class Iterator_t >
requires std::same_as<mysql::ranges::Iterator_value_type<Iterator_t>, Mapped_t>
auto mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::assign ( const Iterator_t it1,
const Iterator_t it2 
)
inlinenoexcept

◆ assign() [3/5]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
template<class Iterator_t >
auto mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::assign ( const Iterator_t it1,
const Iterator_t it2 
)
inlinenoexcept

◆ assign() [4/5]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
template<class Other_t >
auto mysql::containers::Basic_container_wrapper< Self_tp, Wrapped_tp, shall_catch >::assign ( const Other_t &  other)
inlinenoexcept

Copy-assign the other object to the wrapped object.

This is enabled provided that the subclass defines an assign member taking two iterators.

◆ assign() [5/5]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
void mysql::containers::Basic_container_wrapper< Self_tp, Wrapped_tp, shall_catch >::assign ( Self_t &&  other)
inlinenoexcept

Move-assign the other object to the wrapped object.

This is enabled provided that the wrapped class is nothrow-move-assignable.

◆ do_find()

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
template<class Iter >
static Iter mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::do_find ( auto &  the_map,
Iter &  cursor,
const Key_t key 
)
inlinestaticprivatenoexcept

Common implementation of the const and non-const versions of find(cursor, key).

Template Parameters
IterOne of Iterator_t or Const_iterator_t
Parameters
the_mapReference or const reference to map().
cursorCursor position.
keyKey to search for.
Returns
Iterator to element equal to key, or end() if none found.

◆ emplace() [1/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
auto mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::emplace ( const Key_t key)
inlinenoexcept

If no entry with the given key exists, insert one and default-construct the mapped object.

Parameters
keyKey to insert.
Returns
std::optional<Iterator_t>, which holds an iterator to the inserted element if the operation succeeded, and holds no value if an out-of-memory condition occurred.

◆ emplace() [2/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
auto mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::emplace ( Iterator_t cursor,
const Key_t key 
)
inlinenoexcept

If no entry with the given key exists, insert one using the given cursor hint, and default-construct the mapped object.

Parameters
[in,out]cursorIterator. If this points to the insertion position, the insertion is O(1) time. Will be updated to the next element after the inserted one.
keyKey to insert.
Returns
std::optional<Iterator_t>, which holds an iterator to the inserted element if the operation succeeded, and holds no value if an out-of-memory condition occurred.

◆ erase() [1/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::erase ( const Iterator_t first,
const Iterator_t last 
)
inline

Remove the range of elements from first, inclusive, to last, exclusive.

Returns
Iterator to the next element after the removed one.

◆ erase() [2/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::erase ( const Iterator_t iterator)
inline

Remove the element that the iterator points to.

Returns
Iterator to the next element after the removed one.

◆ find() [1/4]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Const_iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::find ( const Key_t key) const
inlinenoexcept
Returns
const iterator to the entry with the given key, or end() if there is no entry for the given key.

◆ find() [2/4]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::find ( const Key_t key)
inlinenoexcept
Returns
iterator to the entry with the given key, or end() if there is no entry for the given key.

◆ find() [3/4]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Const_iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::find ( Const_iterator_t cursor,
const Key_t key 
) const
inlinenoexcept
Returns
const iterator to the entry with the given key, or end() if there is no entry for the given key. This uses the given cursor hint to make the operation constant-time in case key <= cursor->first.
Parameters
[in,out]cursorIterator hint. If this is greater than map::lower_bound(key), the behavior is undefined. It will be updated to the upper bound for the key. Thus, it is suitable to use in successive calls to this function with increasing keys.
keyThe key to find.
Returns
Iterator to element equal to key, or end if no such element exists.

◆ find() [4/4]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::find ( Iterator_t cursor,
const Key_t key 
)
inlinenoexcept
Returns
iterator to the entry with the given key, or end() if there is no entry for the given key. This uses the given cursor hint to make the operation constant-time in case key <= cursor->first.
Parameters
[in,out]cursorIterator hint. If this is greater than map::lower_bound(key), the behavior is undefined. It will be updated to the upper bound for the key. Thus, it is suitable to use in successive calls to this function with increasing keys.
keyThe key to find.
Returns
Iterator to element equal to key, or end if no such element exists.

◆ map() [1/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
const auto & mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::map ( ) const
inlinenoexcept
Returns
Const reference to the underlying map object.

◆ map() [2/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
auto & mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::map ( )
inlinenoexcept
Returns
Non-const reference to the underlying map object.

◆ operator=() [1/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
This_t & mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::operator= ( const This_t )
delete

◆ operator=() [2/2]

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
This_t & mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::operator= ( This_t &&  )
defaultnoexcept

◆ steal_and_insert()

template<Is_nested_set_traits Set_traits_tp, class Map_tp >
Iterator_t mysql::sets::Map_nested_storage< Set_traits_tp, Map_tp >::steal_and_insert ( const Iterator_t position,
This_t source,
Iterator_t  steal_element 
)
inlinenoexcept

If no entry with the given key exists, insert one and default-construct the mapped object.

Parameters
positionPosition before which the element shall be inserted.
sourceMap_nested_storage from which element shall be stolen.
steal_elementIterator to element in source that shall be stolen.
Returns
iterator to the inserted element

This operation cannot fail.


The documentation for this class was generated from the following file: