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::intrusive_multiset< T, Hook, Compare > Class Template Reference

#include <intrusive_set.h>

Classes

class  const_iterator_impl
 
class  iterator_impl
 
class  reverse_iterator_impl
 

Public Types

typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef AZStd::size_t difference_type
 
typedef AZStd::size_t size_type
 
typedef T KeyType
 
typedef Compare KeyCompare
 
typedef T value_type
 
typedef T node_type
 
typedef node_type * node_ptr_type
 
typedef const node_type * const_node_ptr_type
 
typedef intrusive_multiset_node< T > hook_node_type
 
typedef hook_node_typehook_node_ptr_type
 
typedef iterator_impl iterator
 
typedef const_iterator_impl const_iterator
 
typedef reverse_iterator_impl< iteratorreverse_iterator
 
typedef reverse_iterator_impl< const_iteratorconst_reverse_iterator
 

Public Member Functions

AZ_FORCE_INLINE intrusive_multiset (const KeyCompare &keyEq)
 
template<class InputIterator >
AZ_FORCE_INLINE intrusive_multiset (const InputIterator &first, const InputIterator &last)
 
AZ_FORCE_INLINE intrusive_multiset (const this_type &rhs)
 
AZ_FORCE_INLINE this_typeoperator= (const this_type &rhs)
 
AZ_FORCE_INLINE const_iterator begin () const
 
AZ_FORCE_INLINE iterator begin ()
 
AZ_FORCE_INLINE const_iterator end () const
 
AZ_FORCE_INLINE iterator end ()
 
AZ_FORCE_INLINE reverse_iterator rbegin ()
 
AZ_FORCE_INLINE const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
AZ_FORCE_INLINE reverse_iterator rend ()
 
AZ_FORCE_INLINE const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
AZ_FORCE_INLINE const_iterator root () const
 
AZ_FORCE_INLINE iterator root ()
 
AZ_FORCE_INLINE const_iterator minimum () const
 
AZ_FORCE_INLINE iterator minimum ()
 
AZ_FORCE_INLINE const_iterator maximum () const
 
AZ_FORCE_INLINE iterator maximum ()
 
AZ_FORCE_INLINE iterator lower_bound (const KeyType &key)
 
AZ_FORCE_INLINE const_iterator lower_bound (const KeyType &key) const
 
template<class ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, iteratorlower_bound (const ComparableToKey &key)
 
template<class ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, const_iteratorlower_bound (const ComparableToKey &key) const
 
AZ_FORCE_INLINE iterator upper_bound (const KeyType &key)
 
AZ_FORCE_INLINE const_iterator upper_bound (const KeyType &key) const
 
template<class ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, iteratorupper_bound (const ComparableToKey &key)
 
template<class ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, const_iteratorupper_bound (const ComparableToKey &key) const
 
AZ_FORCE_INLINE iterator find (const KeyType &key)
 
AZ_FORCE_INLINE const_iterator find (const KeyType &key) const
 
iterator insert (T *value)
 
AZ_FORCE_INLINE iterator insert (T &value)
 
template<class InputIterator >
AZ_FORCE_INLINE void insert (InputIterator first, InputIterator last)
 
void erase (T *value)
 
AZ_FORCE_INLINE void erase (T &value)
 
AZ_FORCE_INLINE iterator erase (const_iterator where)
 
template<class InputIterator >
AZ_FORCE_INLINE void erase (InputIterator first, InputIterator last)
 
AZ_FORCE_INLINE void clear ()
 
AZ_FORCE_INLINE AZStd::size_t size () const
 
AZ_FORCE_INLINE bool empty () const
 
int validate_iterator (const const_iterator &iter) const
 
int validate_iterator (const iterator &iter) const
 
void leak_and_reset ()
 Reset the container without going to unhook any elements.
 

Protected Member Functions

node_ptr_type DoLowerBound (const KeyType &key)
 
const_node_ptr_type DoLowerBound (const KeyType &key) const
 
template<typename ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, node_ptr_type > DoLowerBound (const ComparableToKey &key)
 
template<typename ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, const_node_ptr_type > DoLowerBound (const ComparableToKey &key) const
 
node_ptr_type DoUpperBound (const KeyType &key)
 
const_node_ptr_type DoUpperBound (const KeyType &key) const
 
template<typename ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, node_ptr_type > DoUpperBound (const ComparableToKey &key)
 
template<typename ComparableToKey >
enable_if_t< Internal::is_transparent< Compare, ComparableToKey >::value, const_node_ptr_type > DoUpperBound (const ComparableToKey &key) const
 
void setNil (node_ptr_type node) const
 
void AttachTo (node_ptr_type node, node_ptr_type parent, SideType s) const
 
void Rotate (node_ptr_type node, SideType side) const
 
void Substitute (node_ptr_type node, node_ptr_type child) const
 
void Switch (node_ptr_type node1, node_ptr_type node2) const
 
void Link (node_ptr_type node1, node_ptr_type node2) const
 
void Unlink (node_ptr_type node) const
 
void InsertFixup (node_ptr_type node)
 
void EraseFixup (node_ptr_type node)
 
AZ_FORCE_INLINE node_ptr_type get_head ()
 
AZ_FORCE_INLINE node_ptr_type get_root ()
 
AZ_FORCE_INLINE const_node_ptr_type get_head () const
 
AZ_FORCE_INLINE const_node_ptr_type get_root () const
 

Static Protected Member Functions

static node_ptr_type MinOrMax (const_node_ptr_type node, SideType side)
 

Protected Attributes

aligned_storage< sizeof(node_type), alignment_of< node_type >::value >::type m_head
 
AZStd::size_t m_numElements
 
KeyCompare m_keyCompare
 

Friends

class const_iterator_impl
 
class iterator_impl
 

Detailed Description

template<class T, class Hook, class Compare = AZStd::less<T>>
class AZStd::intrusive_multiset< T, Hook, Compare >

Intrusive multiset container is a AZStd extension container.

It uses the intrusive_multiset_node contained in the provided user type T. You have 2 choices you can make your T type to either inherit from intrusive_multiset_node or just have intrusive_multiset_node as a public member. Based on which option you prefer you should use the appropriate hook type. Hook parameter should be intrusive_multiset_base_hook (if you inherit the intrusive_multiset_node) or intrusive_multiset_member_hook if you have it as a public member. Intrusive containers never allocate any memory, destroy or create any objects. Just used the provided nodes to store it's information. Generally speaking intrusive containers are better for the cache (assuming you are operating on the objects you are iterating) You can see examples of all that AZStdExamples.

Member Function Documentation

◆ MinOrMax()

template<class T , class Hook , class Compare = AZStd::less<T>>
static node_ptr_type AZStd::intrusive_multiset< T, Hook, Compare >::MinOrMax ( const_node_ptr_type  node,
SideType  side 
)
inlinestaticprotected

pre-condition

Parameters
nodemust be non-nullptr

Member Data Documentation

◆ m_head

template<class T , class Hook , class Compare = AZStd::less<T>>
aligned_storage<sizeof(node_type),alignment_of<node_type>::value>::type AZStd::intrusive_multiset< T, Hook, Compare >::m_head
protected

OK we face different problems when we implement intrusive list. We choose to create fake node_type as a head node! Why ? There are 2 general ways to solve this issue:

  1. Store the head and tail pointer here and store pointer to the list in the iterator. This makes iterator 2 size, plus operators – and ++ include an if. This is the case because we need end iterator (which will be NULL). And we can't move it.
  2. We can store the base class in the iterator, and every time we need the value we compute the hook offset and recast the pointer. all of this is fine, but we need to have a "simple" way to debug our containers" in a easy way. So at this stage we consider the wasting a memory for a fake head node as the best solution, while we can debug the container. This can change internally at any moment if needed, no interface change will occur.

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