RPNX::DataStructures
Header-only C++ data structures and supporting utilities.
Loading...
Searching...
No Matches
rpnx::map< Key, T, Compare, Allocator > Class Template Reference

Ordered key-value container with size-first ordering. More...

#include <map.hpp>

Public Types

using underlying_type = std::map< Key, T, Compare, Allocator >
 Underlying ordered associative container type.
 
using key_type = typename underlying_type::key_type
 Key type used to order and identify elements.
 
using mapped_type = typename underlying_type::mapped_type
 Value associated with each key.
 
using value_type = typename underlying_type::value_type
 Stored key-value pair type.
 
using size_type = typename underlying_type::size_type
 Unsigned type used for element counts.
 
using difference_type = typename underlying_type::difference_type
 Signed type used for iterator distances.
 
using key_compare = typename underlying_type::key_compare
 Function object used to order keys.
 
using value_compare = typename underlying_type::value_compare
 Function object used to order stored key-value pairs by key.
 
using allocator_type = typename underlying_type::allocator_type
 Allocator type used to manage nodes.
 
using reference = typename underlying_type::reference
 Mutable stored-value reference type.
 
using const_reference = typename underlying_type::const_reference
 Immutable stored-value reference type.
 
using pointer = typename underlying_type::pointer
 Mutable stored-value pointer type.
 
using const_pointer = typename underlying_type::const_pointer
 Immutable stored-value pointer type.
 
using iterator = typename underlying_type::iterator
 Mutable bidirectional iterator type.
 
using const_iterator = typename underlying_type::const_iterator
 Immutable bidirectional iterator type.
 
using reverse_iterator = typename underlying_type::reverse_iterator
 Mutable reverse-iterator type.
 
using const_reverse_iterator = typename underlying_type::const_reverse_iterator
 Immutable reverse-iterator type.
 
using node_type = typename underlying_type::node_type
 Owning handle for an extracted node.
 
using insert_return_type = typename underlying_type::insert_return_type
 Result returned when inserting a node handle without a hint.
 

Public Member Functions

 map ()=default
 Constructs an empty map.
 
 map (Compare const &comp, Allocator const &alloc=Allocator())
 Constructs an empty map with a comparator and allocator.
 
 map (Allocator const &alloc)
 Constructs an empty map with an allocator.
 
template<typename InputIt>
 map (InputIt first, InputIt last, Compare const &comp=Compare(), Allocator const &alloc=Allocator())
 Constructs a map from an iterator range.
 
template<typename InputIt>
 map (InputIt first, InputIt last, Allocator const &alloc)
 Constructs a map from an iterator range and allocator.
 
 map (std::initializer_list< value_type > init, Compare const &comp=Compare(), Allocator const &alloc=Allocator())
 Constructs a map from an initializer list.
 
 map (std::initializer_list< value_type > init, Allocator const &alloc)
 Constructs a map from an initializer list and allocator.
 
 map (map const &)=default
 Copy-constructs a map.
 
 map (map &&) noexcept(std::is_nothrow_move_constructible_v< underlying_type >)=default
 Move-constructs a map.
 
 map (map const &other, Allocator const &alloc)
 Copy-constructs a map using the specified allocator.
 
 map (map &&other, Allocator const &alloc)
 Move-constructs a map using the specified allocator.
 
mapoperator= (map const &)=default
 Copy-assigns another map.
 
mapoperator= (map &&) noexcept(std::is_nothrow_move_assignable_v< underlying_type >)=default
 Move-assigns another map.
 
mapoperator= (std::initializer_list< value_type > init)
 Replaces the contents with an initializer list.
 
allocator_type get_allocator () const noexcept
 Returns the allocator used by this map.
 
T & at (Key const &key)
 Returns the mapped value for an existing key.
 
T const & at (Key const &key) const
 Returns the mapped value for an existing key.
 
T & operator[] (Key const &key)
 Returns the mapped value, inserting a default value when absent.
 
T & operator[] (Key &&key)
 Returns the mapped value, moving the key into a new element when absent.
 
iterator begin () noexcept
 Returns an iterator to the first key-value pair.
 
const_iterator begin () const noexcept
 Returns an immutable iterator to the first key-value pair.
 
const_iterator cbegin () const noexcept
 Returns an immutable iterator to the first key-value pair.
 
iterator end () noexcept
 Returns an iterator one past the final key-value pair.
 
const_iterator end () const noexcept
 Returns an immutable iterator one past the final key-value pair.
 
const_iterator cend () const noexcept
 Returns an immutable iterator one past the final key-value pair.
 
reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the final key-value pair.
 
const_reverse_iterator rbegin () const noexcept
 Returns an immutable reverse iterator to the final key-value pair.
 
const_reverse_iterator crbegin () const noexcept
 Returns an immutable reverse iterator to the final key-value pair.
 
reverse_iterator rend () noexcept
 Returns a reverse iterator preceding the first key-value pair.
 
const_reverse_iterator rend () const noexcept
 Returns an immutable reverse iterator preceding the first key-value pair.
 
const_reverse_iterator crend () const noexcept
 Returns an immutable reverse iterator preceding the first key-value pair.
 
bool empty () const noexcept
 Returns whether the map has no elements.
 
size_type size () const noexcept
 Returns the number of stored key-value pairs.
 
size_type max_size () const noexcept
 Returns the maximum number of elements supported by the implementation.
 
void clear () noexcept
 Removes all key-value pairs.
 
std::pair< iterator, bool > insert (value_type const &value)
 Inserts a key-value pair if its key is absent.
 
std::pair< iterator, bool > insert (value_type &&value)
 Inserts a key-value pair by moving it if its key is absent.
 
template<typename P>
requires std::is_constructible_v< value_type, P&& >
std::pair< iterator, bool > insert (P &&value)
 Inserts a value constructible as a key-value pair if its key is absent.
 
iterator insert (const_iterator hint, value_type const &value)
 Inserts a copied key-value pair using an ordering hint.
 
iterator insert (const_iterator hint, value_type &&value)
 Inserts a moved key-value pair using an ordering hint.
 
template<typename P>
requires std::is_constructible_v< value_type, P&& >
iterator insert (const_iterator hint, P &&value)
 Inserts a pair-like value using an ordering hint.
 
template<typename InputIt>
void insert (InputIt first, InputIt last)
 Inserts every key-value pair in an iterator range.
 
void insert (std::initializer_list< value_type > init)
 Inserts key-value pairs from an initializer list.
 
insert_return_type insert (node_type &&node)
 Inserts an extracted node if its key is absent.
 
iterator insert (const_iterator hint, node_type &&node)
 Inserts an extracted node using an ordering hint.
 
template<typename... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 Constructs a key-value pair in place if its key is absent.
 
template<typename... Args>
iterator emplace_hint (const_iterator hint, Args &&... args)
 Constructs a key-value pair in place using an ordering hint.
 
template<typename... Args>
std::pair< iterator, bool > try_emplace (Key const &key, Args &&... args)
 Constructs a mapped value only when a copied key is absent.
 
template<typename... Args>
std::pair< iterator, bool > try_emplace (Key &&key, Args &&... args)
 Constructs a mapped value only when a moved key is absent.
 
template<typename... Args>
iterator try_emplace (const_iterator hint, Key const &key, Args &&... args)
 Constructs a mapped value for an absent copied key using an ordering hint.
 
template<typename... Args>
iterator try_emplace (const_iterator hint, Key &&key, Args &&... args)
 Constructs a mapped value for an absent moved key using an ordering hint.
 
template<typename M>
std::pair< iterator, bool > insert_or_assign (Key const &key, M &&obj)
 Inserts a copied key or assigns its existing mapped value.
 
template<typename M>
std::pair< iterator, bool > insert_or_assign (Key &&key, M &&obj)
 Inserts a moved key or assigns its existing mapped value.
 
template<typename M>
iterator insert_or_assign (const_iterator hint, Key const &key, M &&obj)
 Inserts a copied key or assigns its value using an ordering hint.
 
template<typename M>
iterator insert_or_assign (const_iterator hint, Key &&key, M &&obj)
 Inserts a moved key or assigns its value using an ordering hint.
 
iterator erase (const_iterator pos)
 Erases one element.
 
iterator erase (const_iterator first, const_iterator last)
 Erases a range.
 
size_type erase (Key const &key)
 Erases the element with a key.
 
void swap (map &other) noexcept(noexcept(m_map.swap(other.m_map)))
 Exchanges contents with another map.
 
node_type extract (const_iterator pos)
 Removes an element without destroying it.
 
node_type extract (Key const &key)
 Removes an element by key without destroying it.
 
template<typename C2>
void merge (map< Key, T, C2, Allocator > &source)
 Transfers non-duplicate nodes from another RPNX map.
 
template<typename C2>
void merge (map< Key, T, C2, Allocator > &&source)
 Transfers non-duplicate nodes from another RPNX map.
 
template<typename C2>
void merge (std::map< Key, T, C2, Allocator > &source)
 Transfers non-duplicate nodes from a standard map.
 
template<typename C2>
void merge (std::map< Key, T, C2, Allocator > &&source)
 Transfers non-duplicate nodes from a standard map.
 
size_type count (Key const &key) const
 Counts elements matching a key.
 
iterator find (Key const &key)
 Finds an element by key.
 
const_iterator find (Key const &key) const
 Finds an element by key.
 
bool contains (Key const &key) const
 Tests whether a key is present.
 
std::pair< iterator, iteratorequal_range (Key const &key)
 Finds the range matching a key.
 
std::pair< const_iterator, const_iteratorequal_range (Key const &key) const
 Finds the range matching a key.
 
iterator lower_bound (Key const &key)
 Finds the first element not ordered before a key.
 
const_iterator lower_bound (Key const &key) const
 Finds the first element not ordered before a key.
 
iterator upper_bound (Key const &key)
 Finds the first element ordered after a key.
 
const_iterator upper_bound (Key const &key) const
 Finds the first element ordered after a key.
 
key_compare key_comp () const
 Returns the key-ordering predicate.
 
value_compare value_comp () const
 Returns the stored-value ordering predicate.
 

Friends

template<typename K, typename U, typename C, typename A>
bool operator== (map< K, U, C, A > const &lhs, map< K, U, C, A > const &rhs)
 Grants equality comparison access to the underlying map.
 
template<typename K, typename U, typename C, typename A>
bool operator< (map< K, U, C, A > const &lhs, map< K, U, C, A > const &rhs)
 Grants less-than comparison access to the underlying map.
 
template<typename K, typename U, typename C, typename A>
auto operator<=> (map< K, U, C, A > const &lhs, map< K, U, C, A > const &rhs) -> decltype(std::declval< typename map< K, U, C, A >::underlying_type const & >()<=> std::declval< typename map< K, U, C, A >::underlying_type const & >())
 Grants three-way comparison access to the underlying map.
 

Detailed Description

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
class rpnx::map< Key, T, Compare, Allocator >

Ordered key-value container with size-first ordering.

rpnx::map is currently implemented as a wrapper around std::map and exposes the same common container operations. Its relational comparisons differ from std::map: a map with fewer elements compares less than a map with more elements, regardless of the stored key-value pairs. Maps with equal sizes compare through the underlying std::map.

Template Parameters
KeyStored key type.
TStored mapped value type.
CompareOrdering predicate used by the underlying std::map.
AllocatorAllocator used by the underlying std::map.

Constructor & Destructor Documentation

◆ map() [1/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( Compare const & comp,
Allocator const & alloc = Allocator() )
inlineexplicit

Constructs an empty map with a comparator and allocator.

Parameters
compComparator used to order keys.
allocAllocator used to allocate elements.

◆ map() [2/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( Allocator const & alloc)
inlineexplicit

Constructs an empty map with an allocator.

Parameters
allocAllocator used to allocate elements.

◆ map() [3/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename InputIt>
rpnx::map< Key, T, Compare, Allocator >::map ( InputIt first,
InputIt last,
Compare const & comp = Compare(),
Allocator const & alloc = Allocator() )
inline

Constructs a map from an iterator range.

Template Parameters
InputItInput iterator type.
Parameters
firstFirst element in the source range.
lastOne-past-last element in the source range.
compComparator used to order keys.
allocAllocator used to allocate elements.

◆ map() [4/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename InputIt>
rpnx::map< Key, T, Compare, Allocator >::map ( InputIt first,
InputIt last,
Allocator const & alloc )
inline

Constructs a map from an iterator range and allocator.

Template Parameters
InputItInput iterator type.
Parameters
firstFirst element in the source range.
lastOne-past-last element in the source range.
allocAllocator used to allocate elements.

◆ map() [5/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( std::initializer_list< value_type > init,
Compare const & comp = Compare(),
Allocator const & alloc = Allocator() )
inline

Constructs a map from an initializer list.

Parameters
initValues to insert.
compComparator used to order keys.
allocAllocator used to allocate elements.

◆ map() [6/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( std::initializer_list< value_type > init,
Allocator const & alloc )
inline

Constructs a map from an initializer list and allocator.

Parameters
initValues to insert.
allocAllocator used to allocate elements.

◆ map() [7/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( map< Key, T, Compare, Allocator > const & other,
Allocator const & alloc )
inline

Copy-constructs a map using the specified allocator.

Parameters
otherMap to copy.
allocAllocator used to allocate elements.

◆ map() [8/8]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
rpnx::map< Key, T, Compare, Allocator >::map ( map< Key, T, Compare, Allocator > && other,
Allocator const & alloc )
inline

Move-constructs a map using the specified allocator.

Parameters
otherMap to move from.
allocAllocator used to allocate elements.

Member Function Documentation

◆ at() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
T & rpnx::map< Key, T, Compare, Allocator >::at ( Key const & key)
inline

Returns the mapped value for an existing key.

Parameters
keyKey to locate.
Returns
A mutable reference to the mapped value.
Exceptions
std::out_of_rangeif the key is absent.

◆ at() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
T const & rpnx::map< Key, T, Compare, Allocator >::at ( Key const & key) const
inline

Returns the mapped value for an existing key.

Parameters
keyKey to locate.
Returns
A mutable reference to the mapped value.
Exceptions
std::out_of_rangeif the key is absent.

◆ begin() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::begin ( ) const
inlinenoexcept

Returns an immutable iterator to the first key-value pair.

Returns
Beginning iterator.

◆ begin() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::begin ( )
inlinenoexcept

Returns an iterator to the first key-value pair.

Returns
Beginning iterator.

◆ cbegin()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::cbegin ( ) const
inlinenoexcept

Returns an immutable iterator to the first key-value pair.

Returns
Beginning iterator.

◆ cend()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::cend ( ) const
inlinenoexcept

Returns an immutable iterator one past the final key-value pair.

Returns
Ending iterator.

◆ contains()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
bool rpnx::map< Key, T, Compare, Allocator >::contains ( Key const & key) const
inline

Tests whether a key is present.

Parameters
keyKey to find.
Returns
true if present.

◆ count()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
size_type rpnx::map< Key, T, Compare, Allocator >::count ( Key const & key) const
inline

Counts elements matching a key.

Parameters
keyKey to find.
Returns
One when present, otherwise zero.

◆ crbegin()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_reverse_iterator rpnx::map< Key, T, Compare, Allocator >::crbegin ( ) const
inlinenoexcept

Returns an immutable reverse iterator to the final key-value pair.

Returns
Beginning reverse iterator.

◆ crend()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_reverse_iterator rpnx::map< Key, T, Compare, Allocator >::crend ( ) const
inlinenoexcept

Returns an immutable reverse iterator preceding the first key-value pair.

Returns
Ending reverse iterator.

◆ emplace()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::emplace ( Args &&... args)
inline

Constructs a key-value pair in place if its key is absent.

Template Parameters
ArgsStored pair constructor argument types.
Parameters
argsArguments forwarded to the stored pair constructor.
Returns
Iterator to the matching element and whether insertion occurred.

◆ emplace_hint()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
iterator rpnx::map< Key, T, Compare, Allocator >::emplace_hint ( const_iterator hint,
Args &&... args )
inline

Constructs a key-value pair in place using an ordering hint.

Template Parameters
ArgsStored pair constructor argument types.
Parameters
hintPosition immediately before which insertion may be efficient.
argsArguments forwarded to the stored pair constructor.
Returns
Iterator to the matching element.

◆ empty()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
bool rpnx::map< Key, T, Compare, Allocator >::empty ( ) const
inlinenoexcept

Returns whether the map has no elements.

Returns
true when empty.

◆ end() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::end ( ) const
inlinenoexcept

Returns an immutable iterator one past the final key-value pair.

Returns
Ending iterator.

◆ end() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::end ( )
inlinenoexcept

Returns an iterator one past the final key-value pair.

Returns
Ending iterator.

◆ equal_range() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
std::pair< iterator, iterator > rpnx::map< Key, T, Compare, Allocator >::equal_range ( Key const & key)
inline

Finds the range matching a key.

Parameters
keyKey to find.
Returns
Pair of lower and upper bounds.

◆ equal_range() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
std::pair< const_iterator, const_iterator > rpnx::map< Key, T, Compare, Allocator >::equal_range ( Key const & key) const
inline

Finds the range matching a key.

Parameters
keyKey to find.
Returns
Pair of lower and upper bounds.

◆ erase() [1/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::erase ( const_iterator first,
const_iterator last )
inline

Erases a range.

Parameters
firstFirst element to erase.
lastOne-past-last element to erase.
Returns
Iterator following the erased range.

◆ erase() [2/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::erase ( const_iterator pos)
inline

Erases one element.

Parameters
posElement to erase.
Returns
Iterator following the erased element.

◆ erase() [3/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
size_type rpnx::map< Key, T, Compare, Allocator >::erase ( Key const & key)
inline

Erases the element with a key.

Parameters
keyKey to erase.
Returns
One if erased, otherwise zero.

◆ extract() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
node_type rpnx::map< Key, T, Compare, Allocator >::extract ( const_iterator pos)
inline

Removes an element without destroying it.

Parameters
posElement to extract.
Returns
Owning handle for the extracted node.

◆ extract() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
node_type rpnx::map< Key, T, Compare, Allocator >::extract ( Key const & key)
inline

Removes an element by key without destroying it.

Parameters
keyKey to extract.
Returns
Owning handle, empty if absent.

◆ find() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::find ( Key const & key)
inline

Finds an element by key.

Parameters
keyKey to find.
Returns
Iterator to the element, or end().

◆ find() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::find ( Key const & key) const
inline

Finds an element by key.

Parameters
keyKey to find.
Returns
Iterator to the element, or end().

◆ get_allocator()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
allocator_type rpnx::map< Key, T, Compare, Allocator >::get_allocator ( ) const
inlinenoexcept

Returns the allocator used by this map.

Returns
Allocator associated with the map.

◆ insert() [1/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::insert ( const_iterator hint,
node_type && node )
inline

Inserts an extracted node using an ordering hint.

Parameters
hintPosition immediately before which insertion may be efficient.
nodeOwning node handle to insert.
Returns
Iterator to the matching element.

◆ insert() [2/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename P>
requires std::is_constructible_v< value_type, P&& >
iterator rpnx::map< Key, T, Compare, Allocator >::insert ( const_iterator hint,
P && value )
inline

Inserts a pair-like value using an ordering hint.

Template Parameters
PSource value type.
Parameters
hintPosition immediately before which insertion may be efficient.
valueValue forwarded to the stored pair constructor.
Returns
Iterator to the matching element.

◆ insert() [3/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::insert ( const_iterator hint,
value_type && value )
inline

Inserts a moved key-value pair using an ordering hint.

Parameters
hintPosition immediately before which insertion may be efficient.
valuePair to move.
Returns
Iterator to the matching element.

◆ insert() [4/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::insert ( const_iterator hint,
value_type const & value )
inline

Inserts a copied key-value pair using an ordering hint.

Parameters
hintPosition immediately before which insertion may be efficient.
valuePair to copy.
Returns
Iterator to the matching element.

◆ insert() [5/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename InputIt>
void rpnx::map< Key, T, Compare, Allocator >::insert ( InputIt first,
InputIt last )
inline

Inserts every key-value pair in an iterator range.

Template Parameters
InputItInput iterator type.
Parameters
firstFirst source element.
lastOne-past-last source element.

◆ insert() [6/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
insert_return_type rpnx::map< Key, T, Compare, Allocator >::insert ( node_type && node)
inline

Inserts an extracted node if its key is absent.

Parameters
nodeOwning node handle to insert.
Returns
Insertion result containing the position, insertion state, and any uninserted node.

◆ insert() [7/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename P>
requires std::is_constructible_v< value_type, P&& >
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::insert ( P && value)
inline

Inserts a value constructible as a key-value pair if its key is absent.

Template Parameters
PSource value type.
Parameters
valueValue forwarded to the stored pair constructor.
Returns
Iterator to the matching element and whether insertion occurred.

◆ insert() [8/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
void rpnx::map< Key, T, Compare, Allocator >::insert ( std::initializer_list< value_type > init)
inline

Inserts key-value pairs from an initializer list.

Parameters
initValues to insert.

◆ insert() [9/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::insert ( value_type && value)
inline

Inserts a key-value pair by moving it if its key is absent.

Parameters
valuePair to move.
Returns
Iterator to the matching element and whether insertion occurred.

◆ insert() [10/10]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::insert ( value_type const & value)
inline

Inserts a key-value pair if its key is absent.

Parameters
valuePair to copy.
Returns
Iterator to the matching element and whether insertion occurred.

◆ insert_or_assign() [1/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename M>
iterator rpnx::map< Key, T, Compare, Allocator >::insert_or_assign ( const_iterator hint,
Key && key,
M && obj )
inline

Inserts a moved key or assigns its value using an ordering hint.

Template Parameters
MSource mapped-value type.
Parameters
hintPosition immediately before which insertion may be efficient.
keyKey to find or move into a new element.
objValue to forward into the mapped value.
Returns
Iterator to the matching element.

◆ insert_or_assign() [2/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename M>
iterator rpnx::map< Key, T, Compare, Allocator >::insert_or_assign ( const_iterator hint,
Key const & key,
M && obj )
inline

Inserts a copied key or assigns its value using an ordering hint.

Template Parameters
MSource mapped-value type.
Parameters
hintPosition immediately before which insertion may be efficient.
keyKey to find or copy into a new element.
objValue to forward into the mapped value.
Returns
Iterator to the matching element.

◆ insert_or_assign() [3/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename M>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::insert_or_assign ( Key && key,
M && obj )
inline

Inserts a moved key or assigns its existing mapped value.

Template Parameters
MSource mapped-value type.
Parameters
keyKey to find or move into a new element.
objValue to forward into the mapped value.
Returns
Iterator to the element and whether insertion occurred.

◆ insert_or_assign() [4/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename M>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::insert_or_assign ( Key const & key,
M && obj )
inline

Inserts a copied key or assigns its existing mapped value.

Template Parameters
MSource mapped-value type.
Parameters
keyKey to find or copy into a new element.
objValue to forward into the mapped value.
Returns
Iterator to the element and whether insertion occurred.

◆ key_comp()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
key_compare rpnx::map< Key, T, Compare, Allocator >::key_comp ( ) const
inline

Returns the key-ordering predicate.

Returns
Copy of the comparator.

◆ lower_bound() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::lower_bound ( Key const & key)
inline

Finds the first element not ordered before a key.

Parameters
keyBoundary key.
Returns
Boundary iterator.

◆ lower_bound() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::lower_bound ( Key const & key) const
inline

Finds the first element not ordered before a key.

Parameters
keyBoundary key.
Returns
Boundary iterator.

◆ max_size()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
size_type rpnx::map< Key, T, Compare, Allocator >::max_size ( ) const
inlinenoexcept

Returns the maximum number of elements supported by the implementation.

Returns
Maximum element count.

◆ merge() [1/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename C2>
void rpnx::map< Key, T, Compare, Allocator >::merge ( map< Key, T, C2, Allocator > && source)
inline

Transfers non-duplicate nodes from another RPNX map.

Template Parameters
C2Source comparator type.
Parameters
sourceMap from which nodes are transferred.

◆ merge() [2/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename C2>
void rpnx::map< Key, T, Compare, Allocator >::merge ( map< Key, T, C2, Allocator > & source)
inline

Transfers non-duplicate nodes from another RPNX map.

Template Parameters
C2Source comparator type.
Parameters
sourceMap from which nodes are transferred.

◆ merge() [3/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename C2>
void rpnx::map< Key, T, Compare, Allocator >::merge ( std::map< Key, T, C2, Allocator > && source)
inline

Transfers non-duplicate nodes from a standard map.

Template Parameters
C2Source comparator type.
Parameters
sourceMap from which nodes are transferred.

◆ merge() [4/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename C2>
void rpnx::map< Key, T, Compare, Allocator >::merge ( std::map< Key, T, C2, Allocator > & source)
inline

Transfers non-duplicate nodes from a standard map.

Template Parameters
C2Source comparator type.
Parameters
sourceMap from which nodes are transferred.

◆ operator=() [1/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
map & rpnx::map< Key, T, Compare, Allocator >::operator= ( map< Key, T, Compare, Allocator > && )
defaultnoexcept

Move-assigns another map.

Returns
Reference to this map.

◆ operator=() [2/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
map & rpnx::map< Key, T, Compare, Allocator >::operator= ( map< Key, T, Compare, Allocator > const & )
default

Copy-assigns another map.

Returns
Reference to this map.

◆ operator=() [3/3]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
map & rpnx::map< Key, T, Compare, Allocator >::operator= ( std::initializer_list< value_type > init)
inline

Replaces the contents with an initializer list.

Parameters
initValues to insert.
Returns
Reference to this map.

◆ operator[]() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
T & rpnx::map< Key, T, Compare, Allocator >::operator[] ( Key && key)
inline

Returns the mapped value, moving the key into a new element when absent.

Parameters
keyKey to find or move into a new element.
Returns
A mutable reference to the mapped value.

◆ operator[]() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
T & rpnx::map< Key, T, Compare, Allocator >::operator[] ( Key const & key)
inline

Returns the mapped value, inserting a default value when absent.

Parameters
keyKey to find or copy into a new element.
Returns
A mutable reference to the mapped value.

◆ rbegin() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_reverse_iterator rpnx::map< Key, T, Compare, Allocator >::rbegin ( ) const
inlinenoexcept

Returns an immutable reverse iterator to the final key-value pair.

Returns
Beginning reverse iterator.

◆ rbegin() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
reverse_iterator rpnx::map< Key, T, Compare, Allocator >::rbegin ( )
inlinenoexcept

Returns a reverse iterator to the final key-value pair.

Returns
Beginning reverse iterator.

◆ rend() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_reverse_iterator rpnx::map< Key, T, Compare, Allocator >::rend ( ) const
inlinenoexcept

Returns an immutable reverse iterator preceding the first key-value pair.

Returns
Ending reverse iterator.

◆ rend() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
reverse_iterator rpnx::map< Key, T, Compare, Allocator >::rend ( )
inlinenoexcept

Returns a reverse iterator preceding the first key-value pair.

Returns
Ending reverse iterator.

◆ size()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
size_type rpnx::map< Key, T, Compare, Allocator >::size ( ) const
inlinenoexcept

Returns the number of stored key-value pairs.

Returns
Element count.

◆ swap()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
void rpnx::map< Key, T, Compare, Allocator >::swap ( map< Key, T, Compare, Allocator > & other)
inlinenoexcept

Exchanges contents with another map.

Parameters
otherMap to exchange with.

◆ try_emplace() [1/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
iterator rpnx::map< Key, T, Compare, Allocator >::try_emplace ( const_iterator hint,
Key && key,
Args &&... args )
inline

Constructs a mapped value for an absent moved key using an ordering hint.

Template Parameters
ArgsMapped-value constructor argument types.
Parameters
hintPosition immediately before which insertion may be efficient.
keyKey to find or move into a new element.
argsArguments forwarded to the mapped-value constructor.
Returns
Iterator to the matching element.

◆ try_emplace() [2/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
iterator rpnx::map< Key, T, Compare, Allocator >::try_emplace ( const_iterator hint,
Key const & key,
Args &&... args )
inline

Constructs a mapped value for an absent copied key using an ordering hint.

Template Parameters
ArgsMapped-value constructor argument types.
Parameters
hintPosition immediately before which insertion may be efficient.
keyKey to find or copy into a new element.
argsArguments forwarded to the mapped-value constructor.
Returns
Iterator to the matching element.

◆ try_emplace() [3/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::try_emplace ( Key && key,
Args &&... args )
inline

Constructs a mapped value only when a moved key is absent.

Template Parameters
ArgsMapped-value constructor argument types.
Parameters
keyKey to find or move into a new element.
argsArguments forwarded to the mapped-value constructor.
Returns
Iterator to the matching element and whether insertion occurred.

◆ try_emplace() [4/4]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
template<typename... Args>
std::pair< iterator, bool > rpnx::map< Key, T, Compare, Allocator >::try_emplace ( Key const & key,
Args &&... args )
inline

Constructs a mapped value only when a copied key is absent.

Template Parameters
ArgsMapped-value constructor argument types.
Parameters
keyKey to find or copy into a new element.
argsArguments forwarded to the mapped-value constructor.
Returns
Iterator to the matching element and whether insertion occurred.

◆ upper_bound() [1/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
iterator rpnx::map< Key, T, Compare, Allocator >::upper_bound ( Key const & key)
inline

Finds the first element ordered after a key.

Parameters
keyBoundary key.
Returns
Boundary iterator.

◆ upper_bound() [2/2]

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
const_iterator rpnx::map< Key, T, Compare, Allocator >::upper_bound ( Key const & key) const
inline

Finds the first element ordered after a key.

Parameters
keyBoundary key.
Returns
Boundary iterator.

◆ value_comp()

template<typename Key, typename T, typename Compare = std::less< Key >, typename Allocator = std::allocator< std::pair< Key const, T > >>
value_compare rpnx::map< Key, T, Compare, Allocator >::value_comp ( ) const
inline

Returns the stored-value ordering predicate.

Returns
Copy of the value comparator.

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