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::list< T, Allocator > Class Template Reference

#include <list.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 Internal::list_node< T > node_type
 
typedef node_type * node_ptr_type
 
typedef Internal::list_node_base base_node_type
 
typedef base_node_type * base_node_ptr_type
 
using iterator_impl = list_iterator< T >
 
using const_iterator_impl = basic_const_iterator< iterator_impl >
 
using iterator = iterator_impl
 
using const_iterator = const_iterator_impl
 
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 list (const allocator_type &allocator)
 
AZ_FORCE_INLINE list (size_type numElements, const_reference value=value_type())
 
AZ_FORCE_INLINE list (size_type numElements, const_reference value, const allocator_type &allocator)
 
AZ_FORCE_INLINE list (const this_type &rhs)
 
template<class InputIterator >
AZ_FORCE_INLINE list (InputIterator first, InputIterator last, const allocator_type &allocator=allocator_type())
 
template<class R , class = enable_if_t<Internal::container_compatible_range<R, value_type>>>
 list (from_range_t, R &&rg, const allocator_type &alloc=Allocator())
 
AZ_FORCE_INLINE list (initializer_list< T > ilist, const allocator_type &alloc=allocator_type())
 
AZ_FORCE_INLINE this_typeoperator= (const this_type &rhs)
 
AZ_INLINE void assign (size_type numElements, const_reference value)
 
template<class InputIterator >
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)
 
AZ_FORCE_INLINE size_type size () const
 
AZ_FORCE_INLINE size_type max_size () const
 
AZ_FORCE_INLINE bool empty () const
 
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 newNumElements, const_reference value=value_type())
 
AZ_FORCE_INLINE reference front ()
 
AZ_FORCE_INLINE const_reference front () const
 
AZ_FORCE_INLINE reference back ()
 
AZ_FORCE_INLINE const_reference back () const
 
AZ_FORCE_INLINE void push_front (const_reference value)
 
template<class R >
auto prepend_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, T > >
 
AZ_FORCE_INLINE void pop_front ()
 
AZ_FORCE_INLINE void push_back (const_reference value)
 
template<class R >
auto append_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, T > >
 
AZ_FORCE_INLINE void pop_back ()
 
template<typename MyAllocator = allocator_type>
 list (this_type &&rhs, typename AZStd::enable_if_t< AZStd::is_default_constructible< MyAllocator >::value > *=nullptr)
 
 list (this_type &&rhs, const allocator_type &allocator)
 
this_typeoperator= (this_type &&rhs)
 
void push_front (T &&value)
 
void push_back (T &&value)
 
iterator insert (const_iterator inserPos, T &&value)
 
template<class ... ArgumentsInputs>
reference emplace_front (ArgumentsInputs &&... arguments)
 
template<class ... ArgumentsInputs>
reference emplace_back (ArgumentsInputs &&... arguments)
 
template<class ... ArgumentsInputs>
iterator emplace (const_iterator insertPos, ArgumentsInputs &&... arguments)
 
iterator insert (const_iterator insertPos, initializer_list< T > ilist)
 
iterator insert (const_iterator insertPos, const_reference value)
 
iterator insert (const_iterator insertPos, size_type numElements, const_reference value)
 
template<class InputIterator >
AZ_FORCE_INLINE 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 erase (const_iterator toErase)
 
AZ_FORCE_INLINE iterator erase (const_iterator first, const_iterator last)
 
AZ_FORCE_INLINE void clear ()
 
void swap (this_type &rhs)
 
void splice (iterator splicePos, this_type &rhs)
 
void splice (iterator splicePos, this_type &rhs, iterator first)
 
void splice (iterator splicePos, this_type &rhs, iterator first, iterator last)
 
auto remove (const_reference value) -> size_type
 
template<class Predicate >
auto remove_if (Predicate pred) -> size_type
 
void unique ()
 
template<class BinaryPredicate >
void unique (BinaryPredicate compare)
 
AZ_FORCE_INLINE void merge (this_type &rhs)
 
template<class Compare >
void merge (this_type &rhs, Compare compare)
 
AZ_FORCE_INLINE void sort ()
 
template<class Compare >
void sort (Compare comp)
 
void reverse ()
 
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 const_iterator &iter) const
 Validates an iter iterator. Returns a combination of iterator_status_flag.
 
int validate_iterator (const iterator &iter) const
 
iterator insert (iterator insertPos)
 
iterator insert_after (iterator insertPos, const_reference value)
 
void insert_after (iterator insertPos, size_type numElements, const_reference value)
 
void leak_and_reset ()
 
node_ptr_type unlink (const_iterator unlinkPos)
 
iterator relink (const_iterator insertPos, const base_node_ptr_type nodeToLink)
 

Protected Member Functions

AZ_FORCE_INLINE void deallocate_node (node_ptr_type node)
 
template<class InputIterator >
AZ_FORCE_INLINE iterator insert_iter (const_iterator insertPos, const InputIterator &first, const InputIterator &last, const true_type &)
 
template<class InputIterator >
AZ_FORCE_INLINE iterator insert_iter (const_iterator insertPos, const InputIterator &first, const InputIterator &last, const false_type &)
 
template<class InputIterator >
void assign_iter (const InputIterator &numElements, const InputIterator &value, const true_type &)
 
template<class InputIterator >
void assign_iter (const InputIterator &first, const InputIterator &last, const false_type &)
 
template<class ... ArgumentsInputs>
reference insert_element (const_iterator insertPos, ArgumentsInputs &&... arguments)
 

Protected Attributes

base_node_type m_head
 
size_type m_numElements {}
 
allocator_type m_allocator
 Instance of the allocator.
 

Detailed Description

template<class T, class Allocator = AZStd::allocator>
class AZStd::list< T, Allocator >

The list container (double linked list) is complaint with CStd (23.2.2). In addition we introduce the following extensions.

The list keep the values in nodes (with prev and next element pointers). Each node is allocated separately, so adding 100 elements will cause 100 allocations, that's why it's generally good idea (when speed is important), to either use fixed_list or pool allocator like static_pool_allocator. To find the node type use AZStd::list::node_type. You can see examples of all that AZStdExamples.
Note
For single linked list use forward_list.

Member Function Documentation

◆ insert()

template<class T , class Allocator = AZStd::allocator>
iterator AZStd::list< T, Allocator >::insert ( iterator  insertPos)
inline

Inserts an element at the user position in the list without a provided instance. This can be used for value types with expensive constructors so we don't want to create temporary one.

◆ leak_and_reset()

template<class T , class Allocator = AZStd::allocator>
void AZStd::list< T, 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.

◆ relink()

template<class T , class Allocator = AZStd::allocator>
iterator AZStd::list< T, Allocator >::relink ( const_iterator  insertPos,
const base_node_ptr_type  nodeToLink 
)
inline

Extension allows for a list node to be relinked to list Requirements: The list node must use the same allocator as the list being linked to

◆ unlink()

template<class T , class Allocator = AZStd::allocator>
node_ptr_type AZStd::list< T, Allocator >::unlink ( const_iterator  unlinkPos)
inline

Extension allows for a list node to be unlinked without deletion This is used to implement a node handle construct in the unordered_map


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