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

#include <forward_list.h>

Public Types

using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using allocator_type = Allocator
 
using iterator = iterator_impl
 
using const_iterator = const_iterator_impl
 
using difference_type = iter_difference_t< iterator >
 
using size_type = make_unsigned_t< difference_type >
 

Public Member Functions

AZ_FORCE_INLINE forward_list (const allocator_type &allocator)
 
AZ_FORCE_INLINE forward_list (size_type numElements, const_reference value=value_type())
 
AZ_FORCE_INLINE forward_list (size_type numElements, const_reference value, const allocator_type &allocator)
 
 forward_list (const forward_list &rhs)
 
 forward_list (forward_list &&rhs)
 
template<class InputIterator >
AZ_FORCE_INLINE forward_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>>>
 forward_list (from_range_t, R &&rg, const allocator_type &alloc=allocator_type())
 
 forward_list (initializer_list< T > list, const allocator_type &allocator=allocator_type())
 
AZ_FORCE_INLINE forward_listoperator= (const forward_list &rhs)
 
forward_listoperator= (forward_list &&rhs)
 
void assign (size_type numElements, const_reference 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)
 
AZ_FORCE_INLINE size_type size () const
 
AZ_FORCE_INLINE size_type max_size () const
 
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 iterator before_begin ()
 
AZ_FORCE_INLINE const_iterator before_begin () const
 
AZ_FORCE_INLINE iterator previous (iterator iter)
 
AZ_FORCE_INLINE const_iterator previous (const_iterator iter)
 
AZ_FORCE_INLINE iterator before_end ()
 
AZ_FORCE_INLINE const_iterator before_end () const
 
void resize (size_type newNumElements, const_reference value=value_type())
 
AZ_FORCE_INLINE reference front ()
 
AZ_FORCE_INLINE const_reference front () const
 
void push_front (const_reference value)
 
void push_front (value_type &&value)
 
template<class... Args>
reference emplace_front (Args &&... args)
 
void pop_front ()
 
template<class R >
auto prepend_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type > >
 
reference back ()
 
const_reference back () const
 
void push_back (const_reference value)
 
void push_back (value_type &&value)
 
template<class... Args>
reference emplace_back (Args &&... args)
 
template<class R >
auto append_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type > >
 
AZ_FORCE_INLINE iterator insert (const_iterator insertPos, const_reference value)
 
AZ_FORCE_INLINE 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 InputIterator >
iterator insert_after (const_iterator insertPos, InputIterator first, InputIterator last)
 
template<class R >
auto insert_range_after (const_iterator insertPos, R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, iterator >
 
iterator insert_after (const_iterator insertPos, initializer_list< T > ilist)
 
iterator insert_after (const_iterator insertPos, const_reference value)
 
iterator insert_after (const_iterator insertPos, value_type &&value)
 
template<class... Args>
iterator emplace_after (const_iterator insertPos, Args &&... args)
 
iterator insert_after (const_iterator insertPos, size_type numElements, const_reference value)
 
iterator erase_after (const_iterator toEraseNext)
 
iterator erase_after (const_iterator constPrevFirst, const_iterator constLast)
 
AZ_FORCE_INLINE iterator erase (const_iterator toErase)
 
AZ_FORCE_INLINE iterator erase (const_iterator first, const_iterator last)
 
void clear ()
 
void swap (this_type &rhs)
 
AZ_FORCE_INLINE void splice (const_iterator splicePos, this_type &rhs)
 
AZ_FORCE_INLINE void splice (const_iterator splicePos, this_type &rhs, const_iterator first)
 
AZ_FORCE_INLINE void splice (const_iterator splicePos, this_type &rhs, const_iterator first, const_iterator last)
 
void splice_after (const_iterator splicePos, this_type &&rhs)
 
void splice_after (const_iterator splicePos, this_type &rhs)
 
void splice_after (const_iterator splicePos, this_type &&rhs, const_iterator beforeFirst)
 
void splice_after (const_iterator splicePos, this_type &rhs, const_iterator beforeFirst)
 
void splice_after (const_iterator splicePos, this_type &&rhs, const_iterator beforeFirst, const_iterator last)
 
void splice_after (const_iterator splicePos, this_type &rhs, const_iterator beforeFirst, const_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 ()
 
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
 
void leak_and_reset ()
 

Protected Member Functions

AZ_FORCE_INLINE void deallocate_node (node_ptr_type node)
 
AZ_FORCE_INLINE base_node_ptr_type previous (base_node_ptr_type iNode)
 
template<class InputIterator >
iterator insert_after_iter (const_iterator insertPos, const InputIterator &first, const InputIterator &last, const true_type &)
 
template<class InputIterator >
iterator insert_after_iter (const_iterator insertPos, InputIterator first, 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 &)
 

Protected Attributes

base_node_type m_head
 Node header.
 
base_node_ptr_type m_lastNode {}
 Cached last valid node.
 
size_type m_numElements {}
 Number of elements so size() is O(1).
 
allocator_type m_allocator
 Instance of the allocator.
 

Friends

bool operator== (const forward_list &left, const forward_list &right)
 
bool operator!= (const forward_list &left, const forward_list &right)
 

Detailed Description

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

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

The forward_list keep the values in nodes (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. You can see examples of all that AZStdExamples.

Member Function Documentation

◆ leak_and_reset()

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

◆ previous()

template<class T , class Allocator = AZStd::allocator>
AZ_FORCE_INLINE base_node_ptr_type AZStd::forward_list< T, Allocator >::previous ( base_node_ptr_type  iNode)
inlineprotected

The iterator to the element before i in the list. Returns the end-iterator, if either i is the begin-iterator or the list empty.


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