Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::map< Key, MappedType, Compare, Allocator > Class Template Reference

#include <map.h>

Classes

class  value_compare
 

Public Types

using traits_type = typename tree_type::traits_type
 
using key_type = typename tree_type::key_type
 
using value_type = typename tree_type::value_type
 
using key_compare = typename tree_type::key_equal
 
using mapped_type = MappedType
 
using allocator_type = typename tree_type::allocator_type
 
using size_type = typename tree_type::size_type
 
using difference_type = typename tree_type::difference_type
 
using pointer = typename tree_type::pointer
 
using const_pointer = typename tree_type::const_pointer
 
using reference = typename tree_type::reference
 
using const_reference = typename tree_type::const_reference
 
using iterator = typename tree_type::iterator
 
using const_iterator = typename tree_type::const_iterator
 
using reverse_iterator = typename tree_type::reverse_iterator
 
using const_reverse_iterator = typename tree_type::const_reverse_iterator
 
using node_type = map_node_handle< map_node_traits< key_type, mapped_type, allocator_type, typename tree_type::node_type, typename tree_type::node_deleter > >
 
using insert_return_type = AssociativeInternal::insert_return_type< iterator, node_type >
 

Public Member Functions

 map (const Compare &comp, const Allocator &alloc=Allocator())
 
template<class InputIterator >
 map (InputIterator first, InputIterator last, const Compare &comp=Compare(), const Allocator &alloc=Allocator())
 
template<class R , class = enable_if_t<Internal::container_compatible_range<R, value_type>>>
 map (from_range_t, R &&rg, const Compare &comp=Compare(), const Allocator &alloc=Allocator())
 
 map (const map &rhs)
 
 map (map &&rhs)
 
 map (const Allocator &alloc)
 
 map (const map &rhs, const type_identity_t< Allocator > &alloc)
 
 map (map &&rhs, const type_identity_t< Allocator > &alloc)
 
 map (initializer_list< value_type > list, const Compare &comp=Compare(), const Allocator &alloc=Allocator())
 
template<class InputIterator >
 map (InputIterator first, InputIterator last, const Allocator &alloc)
 
template<class R , class = enable_if_t<Internal::container_compatible_range<R, value_type>>>
 map (from_range_t, R &&rg, const Allocator &a)
 
 map (initializer_list< value_type > il, const Allocator &a)
 
AZ_FORCE_INLINE this_typeoperator= (const this_type &rhs)
 
AZ_FORCE_INLINE key_compare key_comp () const
 
AZ_FORCE_INLINE value_compare value_comp () const
 
AZ_FORCE_INLINE iterator begin ()
 
AZ_FORCE_INLINE iterator end ()
 
AZ_FORCE_INLINE const_iterator begin () const
 
AZ_FORCE_INLINE const_iterator end () const
 
AZ_FORCE_INLINE reverse_iterator rbegin ()
 
AZ_FORCE_INLINE reverse_iterator rend ()
 
AZ_FORCE_INLINE const_reverse_iterator rbegin () const
 
AZ_FORCE_INLINE const_reverse_iterator rend () const
 
AZ_FORCE_INLINE bool empty () const
 
AZ_FORCE_INLINE size_type size () const
 
AZ_FORCE_INLINE size_type max_size () const
 
MappedType & operator[] (const key_type &key)
 
MappedType & operator[] (key_type &&key)
 
AZ_FORCE_INLINE void swap (this_type &rhs)
 
AZ_FORCE_INLINE pair< iterator, bool > insert (const value_type &value)
 
AZ_FORCE_INLINE iterator insert (const_iterator insertPos, const value_type &value)
 
template<class InputIterator >
void insert (InputIterator first, InputIterator last)
 
template<class R >
auto insert_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type > >
 
AZ_FORCE_INLINE iterator erase (const_iterator erasePos)
 
AZ_FORCE_INLINE size_type erase (const key_type &key)
 
AZ_FORCE_INLINE iterator erase (const_iterator first, const_iterator last)
 
AZ_FORCE_INLINE void clear ()
 
this_typeoperator= (this_type &&rhs)
 
AZStd::pair< iterator, bool > insert (value_type &&value)
 
iterator insert (const_iterator insertPos, value_type &&value)
 
template<class ... InputArguments>
AZStd::pair< iterator, bool > emplace (InputArguments &&... arguments)
 
template<class ... InputArguments>
iterator emplace_hint (const_iterator insertPos, InputArguments &&... arguments)
 
insert_return_type insert (node_type &&nodeHandle)
 
iterator insert (const_iterator hint, node_type &&nodeHandle)
 
template<typename M >
pair< iterator, bool > insert_or_assign (const key_type &key, M &&value)
 
template<typename M >
pair< iterator, bool > insert_or_assign (key_type &&key, M &&value)
 
template<typename M >
iterator insert_or_assign (const_iterator hint, const key_type &key, M &&value)
 
template<typename M >
iterator insert_or_assign (const_iterator hint, key_type &&key, M &&value)
 
template<typename... Args>
pair< iterator, bool > try_emplace (const key_type &key, Args &&... arguments)
 
template<typename... Args>
pair< iterator, bool > try_emplace (key_type &&key, Args &&... arguments)
 
template<typename... Args>
iterator try_emplace (const_iterator hint, const key_type &key, Args &&... arguments)
 
template<typename... Args>
iterator try_emplace (const_iterator hint, key_type &&key, Args &&... arguments)
 
node_type extract (const key_type &key)
 
node_type extract (const_iterator it)
 
const_iterator find (const key_type &key) const
 
iterator find (const key_type &key)
 
bool contains (const key_type &key) const
 
size_type count (const key_type &key) const
 
iterator lower_bound (const key_type &key)
 
const_iterator lower_bound (const key_type &key) const
 
iterator upper_bound (const key_type &key)
 
const_iterator upper_bound (const key_type &key) const
 
pair< iterator, iterator > equal_range (const key_type &key)
 
pair< const_iterator, const_iterator > equal_range (const key_type &key) const
 
template<typename ComparableToKey >
auto find (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, const_iterator >
 
template<typename ComparableToKey >
auto find (const ComparableToKey &key) -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, iterator >
 
template<typename ComparableToKey >
auto contains (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, bool >
 
template<typename ComparableToKey >
auto count (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, size_type >
 
template<typename ComparableToKey >
auto lower_bound (const ComparableToKey &key) -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, iterator >
 
template<typename ComparableToKey >
auto lower_bound (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, const_iterator >
 
template<typename ComparableToKey >
auto upper_bound (const ComparableToKey &key) -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, iterator >
 
template<typename ComparableToKey >
auto upper_bound (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, const_iterator >
 
template<typename ComparableToKey >
auto equal_range (const ComparableToKey &key) -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, pair< iterator, iterator > >
 
template<typename ComparableToKey >
auto equal_range (const ComparableToKey &key) const -> enable_if_t< Internal::is_transparent< key_compare, ComparableToKey >::value, pair< const_iterator, const_iterator > >
 
Extensions

AZ_FORCE_INLINE pair< iterator, bool > insert (const key_type &key)
 
AZ_FORCE_INLINE allocator_type & get_allocator ()
 
AZ_FORCE_INLINE const allocator_type & get_allocator () const
 
AZ_FORCE_INLINE void set_allocator (const allocator_type &allocator)
 Set the vector allocator. If different than then current all elements will be reallocated.
 
AZ_INLINE bool validate () const
 
AZ_INLINE int validate_iterator (const const_iterator &iter) const
 Validates an iter iterator. Returns a combination of iterator_status_flag.
 
AZ_INLINE int validate_iterator (const iterator &iter) const
 
AZ_FORCE_INLINE void leak_and_reset ()
 

Detailed Description

template<class Key, class MappedType, class Compare = AZStd::less<Key>, class Allocator = AZStd::allocator>
class AZStd::map< Key, MappedType, Compare, Allocator >

Ordered map container is complaint with C++0x (23.4.1) This is an associative container, all keys are unique. insert function will return false, if you try to add key that is in the set.

Check the set AZStdExamples.

Member Function Documentation

◆ insert()

template<class Key , class MappedType , class Compare = AZStd::less<Key>, class Allocator = AZStd::allocator>
AZ_FORCE_INLINE pair< iterator, bool > AZStd::map< Key, MappedType, Compare, Allocator >::insert ( const key_type &  key)
inline

insert and default construct an element

◆ insert_or_assign()

template<class Key , class MappedType , class Compare = AZStd::less<Key>, class Allocator = AZStd::allocator>
template<typename M >
pair< iterator, bool > AZStd::map< Key, MappedType, Compare, Allocator >::insert_or_assign ( const key_type &  key,
M &&  value 
)
inline

C++17 insert_or_assign function assigns the element to the mapped_type if the key exist in the container Otherwise a new value is inserted into the container

◆ leak_and_reset()

template<class Key , class MappedType , class Compare = AZStd::less<Key>, class Allocator = AZStd::allocator>
AZ_FORCE_INLINE void AZStd::map< Key, MappedType, Compare, Allocator >::leak_and_reset ( )
inline

Resets the container without deallocating any memory or calling any destructor. This function should be used when we need very quick tear down. Generally it's used for temporary vectors and we can just nuke them that way. In addition the provided Allocators, has leak and reset flag which will enable automatically this behavior. So this function should be used in special cases AZStdExamples.

Note
This function is added to the vector for consistency. In the vector case we have only one allocation, and if the allocator allows memory leaks it can just leave deallocate function empty, which performance wise will be the same. For more complex containers this will make big difference.

◆ try_emplace()

template<class Key , class MappedType , class Compare = AZStd::less<Key>, class Allocator = AZStd::allocator>
template<typename... Args>
pair< iterator, bool > AZStd::map< Key, MappedType, Compare, Allocator >::try_emplace ( const key_type &  key,
Args &&...  arguments 
)
inline

C++17 try_emplace function that does nothing to the arguments if the key exist in the container, otherwise it constructs the value type as if invoking value_type(AZStd::piecewise_construct, AZStd::forward_as_tuple(AZStd::forward<KeyType>(key)), AZStd::forward_as_tuple(AZStd::forward<Args>(args)...))


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