Open 3D Engine AzCore API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
AZStd::deque< T, Allocator, NumElementsPerBlock, MinMapSize > Class Template Reference

#include <deque.h>

Classes

class  const_iterator_impl
 
class  iterator_impl
 

Public Types

typedef T * pointer
 
typedef T & reference
 
typedef Allocator::difference_type difference_type
 
typedef Allocator::size_type size_type
 
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
 
typedef iterator_impl iterator
 
typedef const_iterator_impl const_iterator
 
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 >
AZ_FORCE_INLINE deque (InputIterator first, InputIterator last)
 
template<class InputIterator >
AZ_FORCE_INLINE deque (InputIterator first, InputIterator last, const Allocator &allocator)
 
 deque (std::initializer_list< T > ilist, const Allocator &alloc=Allocator())
 
this_typeoperator= (const this_type &rhs)
 
AZ_FORCE_INLINE iterator begin ()
 
AZ_FORCE_INLINE const_iterator begin () const
 
AZ_FORCE_INLINE iterator end ()
 
AZ_FORCE_INLINE const_iterator end () const
 
AZ_FORCE_INLINE reverse_iterator rbegin ()
 
AZ_FORCE_INLINE const_reverse_iterator rbegin () const
 
AZ_FORCE_INLINE reverse_iterator rend ()
 
AZ_FORCE_INLINE const_reverse_iterator rend () const
 
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)
 
void pop_back ()
 
AZ_FORCE_INLINE void assign (size_type numElements, const value_type &value)
 
template<class InputIterator >
AZ_FORCE_INLINE void assign (InputIterator first, InputIterator last)
 
iterator insert (const_iterator insertPos, const value_type &value)
 
void insert (const_iterator insertPos, size_type numElements, const value_type &value)
 
AZ_FORCE_INLINE void insert (const_iterator insertPos, std::initializer_list< value_type > list)
 
template<class InputIterator >
AZ_FORCE_INLINE void insert (const_iterator insertPos, InputIterator first, InputIterator last)
 
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>
void 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 ()
 
const AZ_FORCE_INLINE 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 push_front ()
 
void push_back ()
 
void leak_and_reset ()
 

Public Attributes

const typedef T * const_pointer
 
const typedef T & const_reference
 

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::allocator, AZStd::size_t NumElementsPerBlock = AZStd::deque_block<sizeof(T)>::num_elements, AZStd::size_t MinMapSize = 8>
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::allocator, AZStd::size_t NumElementsPerBlock = AZStd::deque_block<sizeof(T)>::num_elements, AZStd::size_t MinMapSize = 8>
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.

◆ push_back()

template<class T , class Allocator = AZStd::allocator, AZStd::size_t NumElementsPerBlock = AZStd::deque_block<sizeof(T)>::num_elements, AZStd::size_t MinMapSize = 8>
void AZStd::deque< T, Allocator, NumElementsPerBlock, MinMapSize >::push_back ( )
inline

Pushes an element at the back of the deque without a provided instance. This can be used for value types with expensive constructors so we don't want to create temporary one.

◆ push_front()

template<class T , class Allocator = AZStd::allocator, AZStd::size_t NumElementsPerBlock = AZStd::deque_block<sizeof(T)>::num_elements, AZStd::size_t MinMapSize = 8>
void AZStd::deque< T, Allocator, NumElementsPerBlock, MinMapSize >::push_front ( )
inline

Pushes an element at the front of the deque without a provided instance. This can be used for value types with expensive constructors so we don't want to create temporary one.


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