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::deque< T, Allocator, NumElementsPerBlock, MinMapSize > Class Template Reference

#include <deque.h>

Public Types

typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef Allocator allocator_type
 
typedef T value_type
 
typedef block_node block_node_type
 
typedef pointer map_node_type
 
typedef map_node_type * map_node_ptr_type
 
using iterator = deque_iterator_impl< T, Allocator, NumElementsPerBlock, MinMapSize >
 
using const_iterator = basic_const_iterator< iterator >
 
using difference_type = typename iterator::difference_type
 
using size_type = make_unsigned_t< difference_type >
 
typedef AZStd::reverse_iterator< iteratorreverse_iterator
 
typedef AZStd::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

AZ_FORCE_INLINE deque (const Allocator &allocator)
 
AZ_FORCE_INLINE deque (size_type numElements)
 
AZ_FORCE_INLINE deque (size_type numElements, const value_type &value)
 
AZ_FORCE_INLINE deque (size_type numElements, const value_type &value, const Allocator &allocator)
 
AZ_FORCE_INLINE deque (const this_type &rhs)
 
template<class InputIterator >
 deque (InputIterator first, InputIterator last, const Allocator &allocator=Allocator())
 
template<class R , class = enable_if_t<Internal::container_compatible_range<R, value_type>>>
 deque (from_range_t, R &&rg, const Allocator &alloc=Allocator())
 
 deque (initializer_list< T > ilist, const Allocator &alloc=Allocator())
 
this_typeoperator= (const this_type &rhs)
 
AZ_FORCE_INLINE iterator begin () noexcept
 
AZ_FORCE_INLINE const_iterator begin () const noexcept
 
AZ_FORCE_INLINE const_iterator cbegin () const noexcept
 
AZ_FORCE_INLINE iterator end () noexcept
 
AZ_FORCE_INLINE const_iterator end () const noexcept
 
AZ_FORCE_INLINE const_iterator cend () const noexcept
 
AZ_FORCE_INLINE reverse_iterator rbegin () noexcept
 
AZ_FORCE_INLINE const_reverse_iterator rbegin () const noexcept
 
AZ_FORCE_INLINE const_reverse_iterator crbegin () const noexcept
 
AZ_FORCE_INLINE reverse_iterator rend () noexcept
 
AZ_FORCE_INLINE const_reverse_iterator rend () const noexcept
 
AZ_FORCE_INLINE const_reverse_iterator crend () const noexcept
 
AZ_FORCE_INLINE void resize (size_type newSize)
 
AZ_FORCE_INLINE void resize (size_type newSize, const value_type &value)
 
AZ_FORCE_INLINE size_type size () const
 
AZ_FORCE_INLINE size_type max_size () const
 
AZ_FORCE_INLINE bool empty () const
 
AZ_FORCE_INLINE const_reference at (size_type offset) const
 
AZ_FORCE_INLINE reference at (size_type offset)
 
AZ_FORCE_INLINE const_reference operator[] (size_type offset) const
 
AZ_FORCE_INLINE reference operator[] (size_type offset)
 
AZ_FORCE_INLINE const_reference front () const
 
AZ_FORCE_INLINE reference front ()
 
AZ_FORCE_INLINE const_reference back () const
 
AZ_FORCE_INLINE reference back ()
 
void push_front (const value_type &value)
 
void pop_front ()
 
void push_back (const value_type &value)
 
template<class R >
auto prepend_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, T > >
 
void pop_back ()
 
template<class R >
auto append_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, T > >
 
AZ_FORCE_INLINE void assign (size_type numElements, const value_type &value)
 
template<class InputIterator >
AZ_FORCE_INLINE void assign (InputIterator first, InputIterator last)
 
template<class R >
auto assign_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type > >
 
void assign (initializer_list< T > iList)
 
iterator insert (const_iterator insertPos, const value_type &value)
 
iterator insert (const_iterator insertPos, size_type numElements, const value_type &value)
 
template<class InputIterator >
iterator insert (const_iterator insertPos, InputIterator first, InputIterator last)
 
template<class R >
auto insert_range (const_iterator insertPos, R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, iterator >
 
iterator insert (const_iterator insertPos, initializer_list< value_type > list)
 
AZ_FORCE_INLINE iterator erase (iterator erasePos)
 
AZ_INLINE iterator erase (const_iterator constFirst, const_iterator constLast)
 
void clear ()
 
void swap (this_type &rhs)
 
 deque (this_type &&rhs)
 
this_typeoperator= (this_type &&rhs)
 
void assign_rv (this_type &&rhs)
 
void push_front (value_type &&value)
 
void push_back (value_type &&value)
 
template<class... Args>
void emplace_front (Args &&... args)
 
template<class... Args>
reference emplace_back (Args &&... args)
 
template<class Args >
iterator insert (const_iterator pos, Args &&args)
 
template<class... Args>
iterator emplace (const_iterator pos, Args &&... args)
 
void swap (this_type &&rhs)
 
Extensions

AZ_FORCE_INLINE allocator_type & get_allocator ()
 
AZ_FORCE_INLINE const allocator_type & get_allocator () const
 
void set_allocator (const allocator_type &allocator)
 Set the vector allocator. If different than then current all elements will be reallocated.
 
bool validate () const
 
int validate_iterator (const iterator &iter) const
 
int validate_iterator (const const_iterator &iter) const
 
void leak_and_reset ()
 

Protected Attributes

map_node_ptr_type m_map {}
 Pointer to array of pointers to blocks.
 
size_type m_mapSize {}
 Size of map array.
 
size_type m_firstOffset {}
 Offset of initial element.
 
size_type m_size {}
 Number of elements in the deque.
 
allocator_type m_allocator {}
 Instance of the allocator.
 

Detailed Description

template<class T, class Allocator, AZStd::size_t NumElementsPerBlock, AZStd::size_t MinMapSize>
class AZStd::deque< T, Allocator, NumElementsPerBlock, MinMapSize >

The deque is complaint with CStd (23.2.1). In addition we introduce the following extensions.

As you know Deque allocate memory in blocks. Each block has NumElementsPerBlock * sizeof(T) size. As extension you are allowed to control the number of elements per block or the minimal map size. This way you can get the optimal balance between memory usage and number of allocation. Unless speed is critical you should not worry about that too much and use the default settings. If you want to pool or just know the node size you can use deque::block_node_type.

Check the deque AZStdExamples.

Attention
If you customize the block and map sizes make sure that NumElementsPerBlock and MinMapSize are >= 1.

Member Function Documentation

◆ leak_and_reset()

template<class T , class Allocator , AZStd::size_t NumElementsPerBlock, AZStd::size_t MinMapSize>
void AZStd::deque< T, Allocator, NumElementsPerBlock, MinMapSize >::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.

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