STD::DEQUE(3cxx)
π NAME π
std::deque< _Tp, _Alloc > β bestie, welcome to the manual page for std::deque< _Tp, _Alloc >, straight out of the 3cxx manual section (that's the (3cxx) bit, iykyk π
).
Okay so what is she? A standard container using fixed-size memory allocation and constant-time manipulation of elements at either end. Like a glow-up of a vector where both ends get main character energy. β¨
β¨ SYNOPSIS β¨
#include <deque>
Inherits std::_Deque_base< _Tp, _Alloc >. π«Ά
π Public Types π
typedef _Alloc allocator_typeβ the allocator's type, slaying under an alias π«typedef _Base::const_iterator const_iteratorβ iterator but make it can't touch this πtypedef _Alloc_traits::const_pointer const_pointerβ a pointer that knows its place (const) πtypedef _Alloc_traits::const_reference const_referenceβ a const reference, respectfully β¨typedef std::reverse_iterator< const_iterator > const_reverse_iteratorβ a const iterator that walks backwards, iconic π¦typedef ptrdiff_t difference_typeβ the difference type, literallyptrdiff_tπtypedef _Base::iterator iteratorβ the iterator iterator, no cap πΈtypedef _Alloc_traits::pointer pointerβ justpointer, we been knew π₯typedef _Alloc_traits::reference referenceβreference, the non-const one, periodt πtypedef std::reverse_iterator< iterator > reverse_iteratorβ the backwards-walking iterator, so fetch πtypedef size_t size_typeβsize_t, for all your size-related needs βtypedef _Tp value_typeβvalue_type=_Tp, the actual element, the moment π
π Public Member Functions π
Constructor time, bestie β there are so many ways to build your deque and we're gonna go through every single one π«Ά
deque ()=defaultβ Creates a deque with no elements. Empty queen, zero notes πtemplate<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> deque (_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())β Builds a deque from a range. Give her__firstto__lastand she eats πdeque (const allocator_type &__a)β Creates a deque with no elements. Still empty, but with your allocator πΈdeque (const deque &__x)β Deque copy constructor. Twin energy β¨deque (const deque &__x, const __type_identity_t< allocator_type > &__a)β Copy constructor with alternative allocator. Same vibe, different allocator, we love a remix πdeque (deque &&)=defaultβ Deque move constructor. She's moving, don't ask where πdeque (deque &&__x, const __type_identity_t< allocator_type > &__a)β Move constructor with alternative allocator. Moving and swapping allocators, versatile icon π¦deque (initializer_list< value_type > __l, const allocator_type &__a=allocator_type())β Builds a deque from an initializer list. Curly braces gang, rise π«Άdeque (size_type __n, const allocator_type &__a=allocator_type())β Creates a deque with default constructed elements.__nof them, freshly default-constructed π«deque (size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())β Creates a deque with copies of an exemplar element.__ncopies of__value, the blueprint, the prototype π~deque ()β the destructor, she says bye cleanly πtemplate<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> void assign (_InputIterator __first, _InputIterator __last)β Assigns a range to a deque.__firstto__last, take it away πvoid assign (initializer_list< value_type > __l)β Assigns an initializer list to a deque.__lgets the job πvoid assign (size_type __n, const value_type &__val)β Assigns a given value to a deque.__nbootlegs of__valπΈreference at (size_type __n)β Provides access to the data contained in the deque. Index__n, please behave π«Άconst_reference at (size_type __n) constβ Provides access to the data contained in the deque. Same deal, but const-flavoured β¨const_reference back () const noexceptβ the const back, no cap πreference back () noexceptβ the mutable back, she's there π₯const_iterator begin () const noexceptβ const begin π¦iterator begin () noexceptβ begin, but make it mutable βconst_iterator cbegin () const noexceptβ the c-flavoured begin, unbothered πconst_iterator cend () const noexceptβ the c-flavoured end πΈvoid clear () noexceptβ wipe her clean, no drama πconst_reverse_iterator crbegin () const noexceptβ const reverse begin, backwards and blessed πconst_reverse_iterator crend () const noexceptβ const reverse end, still going backwards π«template<typename... _Args> iterator emplace (const_iterator __position, _Args &&... __args)β Inserts an object in deque before specified iterator. Builds it in place at__position, efficient queen πtemplate<typename... _Args> reference emplace_back (_Args &&... __args)β emplaces at the back, construct-in-place behaviour π«Άtemplate<typename... _Args> reference emplace_front (_Args &&... __args)β emplaces at the front, same energy, other end β¨bool empty () const noexceptβ is she empty?noexceptabout it πconst_iterator end () const noexceptβ const end π¦iterator end () noexceptβ mutable end πΈiterator erase (const_iterator __first, const_iterator __last)β Remove a range of elements.__firstto__last, gone girl πiterator erase (const_iterator __position)β Remove element at given position. Just the one, at__positionπconst_reference front () const noexceptβ const front, the first one πreference front () noexceptβ mutable front, main character at index zero πallocator_type get_allocator () const noexceptβ Get a copy of the memory allocation object. A copy, bestie, not the original π₯iterator insert (const_iterator __p, initializer_list< value_type > __l)β Inserts an initializer list into the deque. At__p, with__lπtemplate<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> iterator insert (const_iterator __position, _InputIterator __first, _InputIterator __last)β Inserts a range into the deque.__positionfirst, then__firstthrough__lastβiterator insert (const_iterator __position, const value_type &__x)β Inserts given value into deque before specified iterator.__xgoes in before__positionπiterator insert (const_iterator __position, size_type __n, const value_type &__x)β Inserts a number of copies of given data into the deque.__ncopies of__xat__positionπ«Άiterator insert (const_iterator __position, value_type &&__x)β Inserts given rvalue into deque before specified iterator. Rvalue edition, move it along β¨size_type max_size () const noexceptβ the maximum size,noexceptand unbothered πdeque & operator= (const deque &__x)β Deque assignment operator. Copy-assign, twin check πdeque & operator= (deque &&__x) noexcept(_Alloc_traits::_S_always_equal())β Deque move assignment operator. Note thenoexcept(_Alloc_traits::_S_always_equal())β that's conditional noexcept, she's fancy π¦deque & operator= (initializer_list< value_type > __l)β Assigns an initializer list to a deque. Curly braces to the rescue πΈconst_reference operator[] (size_type __n) const noexceptβ Subscript access to the data contained in the deque. Const flavour,noexceptβreference operator[] (size_type __n) noexceptβ Subscript access to the data contained in the deque. Mutable flavour,noexceptπ₯void pop_back () noexceptβ Removes last element. Bye bestie at the back πvoid pop_front () noexceptβ Removes first element. Bye bestie at the front πvoid push_back (const value_type &__x)β Add data to the end of the deque.__xat the back π«Άvoid push_back (value_type &&__x)β push_back but the rvalue one π«void push_front (const value_type &__x)β Add data to the front of the deque.__xat the front πvoid push_front (value_type &&__x)β push_front but the rvalue one πconst_reverse_iterator rbegin () const noexceptβ const reverse begin πreverse_iterator rbegin () noexceptβ mutable reverse begin πΈconst_reverse_iterator rend () const noexceptβ const reverse end π¦reverse_iterator rend () noexceptβ mutable reverse end βvoid resize (size_type __new_size)β Resizes the deque to the specified number of elements.__new_size, that's the number πvoid resize (size_type __new_size, const value_type &__x)β Resizes the deque to the specified number of elements. Same__new_size, and this one takes__xtoo β¨void shrink_to_fit () noexceptβ she shrinks to fit,noexceptabout it πsize_type size () const noexceptβ how many elements? This many π«Άvoid swap (deque &__x) noexceptβ Swaps data with another deque. Trading places with__x,noexceptπ
π¦ Protected Types π¦
enum { _S_initial_map_size }β an enum with_S_initial_map_sizein it, the initial map size vibe πtypedef __gnu_cxx::__alloc_traits< _Map_alloc_type > _Map_alloc_traitsβ alloc traits for the map alloc type, very internal, very demure πΈtypedef _Alloc_traits::template rebind< _Ptr >::other _Map_alloc_typeβ a rebind to_Ptr, giving_Map_alloc_typeπ«typedef _Alloc_traits::pointer _Ptrβ_Ptr, the pointer alias βtypedef _Alloc_traits::const_pointer _Ptr_constβ_Ptr_const, the const pointer alias π₯
π Protected Member Functions π
The internals, bestie β this is the engine room, no cap πͺ
template<typename _ForwardIterator > void _M_assign_aux (_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)β the forward-iterator flavour of_M_assign_auxπ¦template<typename _InputIterator > void _M_assign_aux (_InputIterator __first, _InputIterator __last, std::input_iterator_tag)β the input-iterator flavour of_M_assign_auxπΈvoid _M_deallocate_map (_Map_pointer __p, size_t __n) noexceptβ deallocates a map,__pand__n,noexceptπvoid _M_default_append (size_type __n)β default-appends__nof them πvoid _M_default_initialize ()β default-initializes, the setup moment β¨template<typename _Alloc1 > void _M_destroy_data (iterator __first, iterator __last, const _Alloc1 &)β destroy data from__firstto__lastwith an_Alloc1πvoid _M_destroy_data (iterator __first, iterator __last, const std::allocator< _Tp > &)β thestd::allocator< _Tp >overload of_M_destroy_dataπvoid _M_destroy_data_aux (iterator __first, iterator __last)β the aux version, still destroying data from__firstto__lastπ«Άiterator _M_erase (iterator __first, iterator __last)β internal erase over a range βiterator _M_erase (iterator __pos)β internal erase at one position πvoid _M_erase_at_begin (iterator __pos)β erase starting at begin,__posπvoid _M_erase_at_end (iterator __pos)β erase at the end,__posπΈvoid _M_fill_assign (size_type __n, const value_type &__val)β fill-assign__ncopies of__valπ¦void _M_fill_initialize (const value_type &__value)β Fills the deque with copies of value.__value, over and over β¨void _M_fill_insert (iterator __pos, size_type __n, const value_type &__x)β fill-insert__ncopies of__xat__posπ_Map_alloc_type _M_get_map_allocator () const noexceptβ hands you a_Map_alloc_type,noexceptπtemplate<typename... _Args> iterator _M_insert_aux (iterator __pos, _Args &&... __args)β the aux insert, variadic edition π₯template<typename _ForwardIterator > void _M_insert_aux (iterator __pos, _ForwardIterator __first, _ForwardIterator __last, size_type __n)β aux insert with a forward-iterator range and__nπvoid _M_insert_aux (iterator __pos, size_type __n, const value_type &__x)β aux insert of__ncopies of__xat__posβvoid _M_move_assign1 (deque &&__x, false_type)β move-assign helper,false_typebranch π«void _M_move_assign1 (deque &&__x, true_type) noexceptβ move-assign helper,true_typebranch,noexceptπ«Άvoid _M_move_assign2 (deque &&__x, false_type)β the second move-assign helper,false_typeπΈvoid _M_move_assign2 (deque &&__x, true_type)β the second move-assign helper,true_typeπ¦void _M_range_check (size_type __n) constβ Safety check used only from at(). Only fromat(), bestie β do not come for her elsewhere πtemplate<typename _ForwardIterator > void _M_range_insert_aux (iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)β range-insert aux, forward-iterator tag flavour πtemplate<typename _InputIterator > void _M_range_insert_aux (iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag)β range-insert aux, input-iterator tag flavour πtemplate<typename... _Args> void _M_replace_map (_Args &&... __args)β replaces the map, variadic args and all β¨bool _M_shrink_to_fit ()β the bool-returning shrink-to-fit internals π
π§ the little nested ones π§
These live under _M_shrink_to_fit in the original layout, so here they are, same energy, no elements skipped π«Ά
template<typename _InputIterator > void _M_range_initialize (_InputIterator __first, _InputIterator __last, std::input_iterator_tag)β Fills the deque with whatever is in[first,last). Input-iterator flavour πΈtemplate<typename _ForwardIterator > void _M_range_initialize (_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)β Fills the deque with whatever is in[first,last). Forward-iterator flavour π¦template<typename... _Args> void _M_push_back_aux (_Args &&... __args)β Helper functions for push_* and pop_*. Back edition π«template<typename... _Args> void _M_push_front_aux (_Args &&... __args)β Helper functions for push_* and pop_*. Front edition πvoid _M_pop_back_aux ()β Helper functions for push_* and pop_*. Popping the back πvoid _M_pop_front_aux ()β Helper functions for push_* and pop_*. Popping the front πiterator _M_reserve_elements_at_front (size_type __n)β Memory-handling helpers for the previous internal insert functions. Reserving__nat the front π₯iterator _M_reserve_elements_at_back (size_type __n)β Memory-handling helpers for the previous internal insert functions. Reserving__nat the back πvoid _M_new_elements_at_front (size_type __new_elements)β Memory-handling helpers for the previous internal insert functions. New elements at the front,__new_elementsof them βvoid _M_new_elements_at_back (size_type __new_elements)β Memory-handling helpers for the previous internal insert functions. New elements at the back π«Άvoid _M_reserve_map_at_back (size_type __nodes_to_add=1)β Memory-handling helpers for the major map. At the back, default__nodes_to_add=1πvoid _M_reserve_map_at_front (size_type __nodes_to_add=1)β Memory-handling helpers for the major map. At the front, default__nodes_to_add=1πvoid _M_reallocate_map (size_type __nodes_to_add, bool __add_at_front)β Memory-handling helpers for the major map.__nodes_to_addand__add_at_front, the whole reallocation moment β¨
β Static Protected Member Functions β
static size_t _S_check_init_len (size_t __n, const allocator_type &__a)β static, so she belongs to the class itself, checking init length with__nand__aπ¦static size_type _S_max_size (const _Tp_alloc_type &__a) noexceptβ static max size,noexcept, taking a_Tp_alloc_typeπ
π Detailed Description π
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
class std::deque< _Tp, _Alloc >
okay so bestie, this is the container: "A standard container using fixed-size memory allocation and constant-time manipulation of elements at either end." Both ends. Constant time. She's π iconic π and she knows it.
πΈ Template Parameters πΈ
_Tpβ Type of element. that's what you're storing, bb._Allocβ Allocator type, defaults toallocator<_Tp>.
She meets the requirements of a container, a reversible container, and a sequence β including the optional sequence requirements. overachiever behavior, honestly. π
β οΈ lore drop: in previous HP/SGI versions of deque, there was an extra template parameter so users could control the node size. This extension turned out to violate the C++ standard (it can be detected using template template parameters), and it was removed. so yeah π it's gone, don't come looking for it.
π§ how a deque<Tp> actually manages memory π§
ngl this is the part where everyone zones out, but it's lowkey the coolest bit. Each deque has 4 members:
Tp** _M_mapsize_t _M_map_sizeiterator _M_start,_M_finish
map_size is at least 8. map is an array of map_size pointers-to-nodes. (and okay, <red>the name map has nothing to do with the std::map class</red>, and "nodes" should not be confused with std::list's usage of node. two totally different vibes, don't mix them up π)
A node has no specific type name as such, but it is referred to as node in this file. It is a simple array-of-Tp. If Tp is very large, there will be one Tp element per node (i.e., an array of one). For non-huge Tp's, node size is inversely related to Tp size: the larger the Tp, the fewer Tp's will fit in a node. The goal here is to keep the total size of a node relatively small and constant over different Tp's, to improve allocator efficiency. strategic. deliberate. main character engineering. π
Not every pointer in the map array will point to a node. If the initial number of elements in the deque is small, the middle map pointers will be valid, and the ones at the edges will be unused. This same situation will arise as the map grows: available map pointers, if any, will be on the ends. As new nodes are created, only a subset of the map's pointers need to be copied outward.
β¨ Class invariants β¨
these are the rules. break them and everything falls apart. no cap.
- For any nonsingular iterator
i:i.nodepoints to a member of themaparray. (Yes, you read that correctly:i.nodedoes not actually point to a node.) The member of themaparray is what actually points to the node. π confusing but truei.first == *(i.node)(This points to the node (firstTpelement).)i.last == i.first + node_sizei.curis a pointer in the range[i.first, i.last). NOTE: the implication of this is thati.curis always a dereferenceable pointer, even ifiis a past-the-end iterator.
startandfinishare always nonsingular iterators. NOTE: this means that an empty deque must have one node, a deque with <N elements (where N is the node buffer size) must have one node, a deque with N through (2N-1) elements must have two nodes, etc.- For every node other than
start.nodeandfinish.node, every element in the node is an initialized object. Ifstart.node == finish.node, then[start.cur, finish.cur)are initialized objects, and the elements outside that range are uninitialized storage. Otherwise,[start.cur, start.last)and[finish.first, finish.cur)are initialized objects, and[start.first, start.cur)and[finish.cur, finish.last)are uninitialized storage. [map, map + map_size)is a valid, non-empty range.[start.node, finish.node]is a valid range contained within[map, map + map_size).- A pointer in the range
[map, map + map_size)points to an allocated node if and only if the pointer is in the range[start.node, finish.node].
Here's the magic: nothing in deque is aware of the discontiguous storage! π€― she's living her best life in pieces and doesn't even know it.
The memory setup and layout occurs in the parent, _Base, and the iterator class is entirely responsible for leaping from one node to the next. All the implementation routines for deque itself work only through the start and finish iterators. This keeps the routines simple and sane, and we can use other standard algorithms as well. work smarter not harder, periodt. π«Ά
π οΈ Constructor & Destructor Documentation π οΈ
π deque () [default]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque () [default]
Creates a deque with no elements. empty queen, zero notes, nothing to see here β¨
π deque (const allocator_type &__a) [inline], [explicit]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (const allocator_type & __a) [inline], [explicit]
Creates a deque with no elements.
Parameters
__aβ An allocator object.
π deque (size_type __n, const allocator_type &__a = allocator_type()) [inline], [explicit]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (size_type __n, const allocator_type & __a = allocator_type()) [inline], [explicit]
Creates a deque with default constructed elements.
Parameters
__nβ The number of elements to initially create.__aβ An allocator.
This constructor fills the deque with n default constructed elements.
π deque (size_type __n, const value_type &__value, const allocator_type &__a = allocator_type()) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (size_type __n, const value_type & __value, const allocator_type & __a = allocator_type()) [inline]
Creates a deque with copies of an exemplar element. copy-paste but make it couture π
Parameters
__nβ The number of elements to initially create.__valueβ An element to copy.__aβ An allocator.
This constructor fills the deque with __n copies of __value.
References: std::deque< _Tp, _Alloc >::_M_fill_initialize().
π deque (const deque< _Tp, _Alloc > &__x) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (const deque< _Tp, _Alloc > & __x) [inline]
Deque copy constructor. the classic twin situation π―ββοΈ
Parameters
__xβ A deque of identical element and allocator types.
The newly-created deque uses a copy of the allocator object used by __x (unless the allocator traits dictate a different object).
References: std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::end().
π deque (deque< _Tp, _Alloc > &&) [default]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (deque< _Tp, _Alloc > &&) [default]
Deque move constructor. The newly-created deque contains the exact contents of the moved instance. The contents of the moved instance are a valid, but unspecified deque.
β οΈ "valid, but unspecified" is the standard-library way of saying "she's alive but she's not okay, don't look at her." don't go inspecting the moved-from deque, bestie, that's not her job anymore π
π deque (const deque< _Tp, _Alloc > &__x, const __type_identity_t< allocator_type > &__a) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (const deque< _Tp, _Alloc > & __x, const __type_identity_t< allocator_type > & __a) [inline]
Copy constructor with alternative allocator.
References: std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::end().
π deque (deque< _Tp, _Alloc > &&__x, const __type_identity_t< allocator_type > &__a) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (deque< _Tp, _Alloc > && __x, const __type_identity_t< allocator_type > & __a) [inline]
Move constructor with alternative allocator.
π deque (initializer_list< value_type > __l, const allocator_type &__a = allocator_type()) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::deque (initializer_list< value_type > __l, const allocator_type & __a = allocator_type()) [inline]
Builds a deque from an initializer list. {1, 2, 3} core, tbh π
Parameters
__lβ Aninitializer_list.__aβ An allocator object.
Create a deque consisting of copies of the elements in the initializer_list __l.
This will call the element type's copy constructor N times (where N is __l.size()) and do no memory reallocation. efficient and organized, we love a planner.
References: std::deque< _Tp, _Alloc >::_M_range_initialize().
π deque (_InputIterator __first, _InputIterator __last, const allocator_type &__a = allocator_type()) [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>>
std::deque< _Tp, _Alloc >::deque (_InputIterator __first, _InputIterator __last, const allocator_type & __a = allocator_type()) [inline]
Builds a deque from a range. feed her the range and she eats π½οΈ
Parameters
__firstβ An input iterator.__lastβ An input iterator.__aβ An allocator object.
Create a deque consisting of copies of the elements from [__first, __last).
If the iterators are forward, bidirectional, or random-access, then this will call the elements' copy constructor N times (where N is distance(__first,__last)) and do no memory reallocation. But if only input iterators are used, then this will do at most 2N calls to the copy constructor, and logN memory reallocations. read that again, the iterator category literally changes the cost. know your iterators, iykyk π₯
References: std::__iterator_category(), and std::deque< _Tp, _Alloc >::_M_range_initialize().
π ~deque () [inline]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
std::deque< _Tp, _Alloc >::~deque () [inline]
β οΈ the dtor only erases the elements, and note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. she cleans up her own stuff and only her own stuff. if you put raw pointers in there, that's on you, love π
References: std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::end().
π§ Member Function Documentation π§
π _M_fill_initialize (const value_type &__value) [protected]
template<typename _Tp, typename _Alloc>
void deque::_M_fill_initialize (const value_type & __value) [protected]
Fills the deque with copies of value.
Parameters
__valueβ Initial value.
Returns
Nothing.
Precondition
_M_start and _M_finish have already been initialized, but none of the deque's elements have yet been constructed.
This function is called only when the user provides an explicit size (with or without an explicit exemplar value).
References: std::_Destroy().
Referenced by: std::deque< _Tp, _Alloc >::deque().
π _M_new_elements_at_back (size_type __new_elements) [protected]
template<typename _Tp, typename _Alloc>
void deque::_M_new_elements_at_back (size_type __new_elements) [protected]
Memory-handling helpers for the previous internal insert functions.
References: std::size().
Referenced by: std::deque< _Tp, _Alloc >::_M_reserve_elements_at_back().
π _M_new_elements_at_front (size_type __new_elements) [protected]
template<typename _Tp, typename _Alloc>
void deque::_M_new_elements_at_front (size_type __new_elements) [protected]
Memory-handling helpers for the previous internal insert functions.
References: std::size().
Referenced by: std::deque< _Tp, _Alloc >::_M_reserve_elements_at_front().
π _M_pop_back_aux () [protected]
template<typename _Tp, typename _Alloc>
void deque::_M_pop_back_aux () [protected]
Helper functions for push_* and pop_*. the little backstage crew making the magic happen π¬
Referenced by: std::deque< _Tp, _Alloc >::pop_back().
π _M_pop_front_aux () [protected]
template<typename _Tp, typename _Alloc>
void deque::_M_pop_front_aux () [protected]
Helper functions for push_* and pop_*.
Referenced by: std::deque< _Tp, _Alloc >::pop_front().
π _M_push_back_aux (_Args &&...__args) [protected]
template<typename _Tp, typename _Alloc>
template<typename... _Args>
void deque::_M_push_back_aux (_Args &&... __args) [protected]
Helper functions for push_* and pop_*. variadic, fancy, obsessed π«Ά
References: std::size().
Referenced by: std::deque< _Tp, _Alloc >::push_back().
π _M_push_front_aux (_Args &&...__args) [protected]
template<typename _Tp, typename _Alloc>
template<typename... _Args>
void deque::_M_push_front_aux (_Args &&... __args) [protected]
Helper functions for push_* and pop_*.
References: std::size().
Referenced by: std::deque< _Tp, _Alloc >::push_front().
π _M_range_check (size_type __n) const [inline], [protected]
template<typename _Tp, typename _Alloc = std::allocator<_Tp>>
void std::deque< _Tp, _Alloc >::_M_range_check (size_type __n) const [inline], [protected]
Safety check used only from at().
References: std::deque< _Tp, _Alloc >::size().
Referenced by: std::deque< _Tp, _Alloc >::at(), and std::deque< _Tp, _Alloc >::at().
π«§ _M_range_initialize (<- the forward-iterator version) [protected]
template<typename _Tp , typename _Alloc > template<typename _ForwardIterator >
void deque::_M_range_initialize (_ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag) [protected]
Okay so this one fills the deque with whatever's in [first,last) π
__firstβ an input iterator, bestie.__lastβ also an input iterator.
Returns: nothing. Nada. Zero. π«Ά
Here's the tea: if the iterators are actually forward iterators (or better π₯), then the memory layout can be done all at once. Else we move forward using push_back on each value from the iterator.
References std::_Destroy(), std::advance(), and std::distance().
π«§ _M_range_initialize (<- the input-iterator version) [protected]
template<typename _Tp , typename _Alloc > template<typename _InputIterator >
void deque::_M_range_initialize (_InputIterator __first, _InputIterator
__last, std::input_iterator_tag) [protected]
Same deal, fills the deque with whatever's in [first,last) β¨
__firstβ an input iterator.__lastβ an input iterator.
Returns: nothing, again π
Same logic, iykyk: if the iterators are actually forward iterators (or better), the memory layout can be done all at once. Else we move forward using push_back on each value from the iterator.
Referenced by std::deque< _Tp, _Alloc >::deque(), and std::deque< _Tp, _Alloc >::deque().
πΊοΈ _M_reallocate_map [protected]
template<typename _Tp , typename _Alloc > void deque::_M_reallocate_map
(size_type __nodes_to_add, bool __add_at_front) [protected]
Memory-handling helpers for the major map π§ Makes sure the _M_map has space for new nodes. Does not actually add the nodes β it's giving "reserving the table, not seating the guests" energy.
Heads up: this can invalidate _M_map pointers. (And consequently, deque iterators.) So likeβ¦ don't be holding onto those, bestie π
References std::max().
Referenced by std::deque< _Tp, _Alloc >::_M_reserve_map_at_back(), and std::deque< _Tp, _Alloc >::_M_reserve_map_at_front().
π _M_reserve_elements_at_back [inline], [protected]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::_M_reserve_elements_at_back (size_type __n)
[inline], [protected]
Memory-handling helpers for the previous internal insert functions π«§ That's literally the whole description, she's mysterious like that.
References std::deque< _Tp, _Alloc >::_M_new_elements_at_back().
π _M_reserve_elements_at_front [inline], [protected]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::_M_reserve_elements_at_front (size_type __n)
[inline], [protected]
Same vibe, front side π Memory-handling helpers for the previous internal insert functions.
References std::deque< _Tp, _Alloc >::_M_new_elements_at_front().
πΊοΈ _M_reserve_map_at_back [inline], [protected]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::_M_reserve_map_at_back (size_type
__nodes_to_add = 1) [inline], [protected]
Memory-handling helpers for the major map β¨ Makes sure the _M_map has space for new nodes. Does not actually add the nodes.
Again: can invalidate _M_map pointers. (And consequently, deque iterators.) Consider yourself warned, gorgeous π
Default for __nodes_to_add is 1, for the record.
References std::deque< _Tp, _Alloc >::_M_reallocate_map().
πΊοΈ _M_reserve_map_at_front [inline], [protected]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::_M_reserve_map_at_front (size_type
__nodes_to_add = 1) [inline], [protected]
Mirror image, same lore πͺ Memory-handling helpers for the major map. Makes sure the _M_map has space for new nodes. Does not actually add the nodes. Can invalidate _M_map pointers. (And consequently, deque iterators.) π
__nodes_to_add defaults to 1.
References std::deque< _Tp, _Alloc >::_M_reallocate_map().
π₯ assign (the iterator-range one) [inline]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator , typename =
std::_RequireInputIter<_InputIterator>> void std::deque< _Tp, _Alloc
>::assign (_InputIterator __first, _InputIterator __last) [inline]
Assigns a range to a deque π
__firstβ an input iterator.__lastβ an input iterator.
This function fills a deque with copies of the elements in the range [__first,__last).
Not me reminding you: the assignment completely changes the deque, and the resulting deque's size is the same as the number of elements assigned π
References std::__iterator_category().
π₯ assign (the initializer_list one) [inline]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::assign (initializer_list< value_type > __l)
[inline]
Assigns an initializer list to a deque π
__lβ aninitializer_list.
This function fills a deque with copies of the elements in the initializer_list __l.
Same rule as before: the assignment completely changes the deque, and the resulting deque's size is the same as the number of elements assigned β¨
π₯ assign (the n-copies one) [inline]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::assign (size_type __n, const value_type &
__val) [inline]
Assigns a given value to a deque πΈ
__nβ number of elements to be assigned.__valβ value to be assigned.
This function fills a deque with n copies of the given value. Note that the assignment completely changes the deque and that the resulting deque's size is the same as the number of elements assigned π
π at (the read/write one) [inline]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> reference
std::deque< _Tp, _Alloc >::at (size_type __n) [inline]
Provides access to the data contained in the deque π«Ά
__nβ the index of the element for which data should be accessed.
Returns: read/write reference to data.
Exceptions: std::out_of_range if __n is an invalid index π
This function provides for safer data access. The parameter is first checked that it is in the range of the deque. The function throws out_of_range if the check fails. It's giving "bouncer at the club checking your ID" energy, lowkey iconic π₯
References std::deque< _Tp, _Alloc >::_M_range_check().
π at (the read-only one) [inline]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::deque< _Tp, _Alloc >::at (size_type __n) const
[inline]
Same function, const era β¨
__nβ the index of the element for which data should be accessed.
Returns: read-only (constant) reference to data.
Exceptions: std::out_of_range if __n is an invalid index π
This function provides for safer data access. The parameter is first checked that it is in the range of the deque. The function throws out_of_range if the check fails.
References std::deque< _Tp, _Alloc >::_M_range_check().
π back (const) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::deque< _Tp, _Alloc >::back () const [inline],
[noexcept]
Returns a read-only (constant) reference to the data at the last element of the deque π
References std::deque< _Tp, _Alloc >::end().
π back (read/write) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> reference
std::deque< _Tp, _Alloc >::back () [inline], [noexcept]
Returns a read/write reference to the data at the last element of the deque π
References std::deque< _Tp, _Alloc >::end().
π begin (const) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::deque< _Tp, _Alloc >::begin () const [inline],
[noexcept]
Returns a read-only (constant) iterator that points to the first element in the deque π Iteration is done in ordinary element order.
π begin (read/write) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::begin () [inline], [noexcept]
Returns a read/write iterator that points to the first element in the deque β¨ Iteration is done in ordinary element order.
Referenced by std::deque< _Tp, _Alloc >::deque(), std::deque< _Tp, _Alloc >::deque(), std::deque< _Tp, _Alloc >::~deque(), std::deque< _Tp, _Alloc >::clear(), std::deque< _Tp, _Alloc >::front(), std::deque< _Tp, _Alloc >::front(), std::deque< _Tp, _Alloc >::insert(), std::deque< _Tp, _Alloc >::insert(), std::deque< _Tp, _Alloc >::insert(), std::operator<=>(), and std::deque< _Tp, _Alloc >::operator=().
π cbegin [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::deque< _Tp, _Alloc >::cbegin () const [inline],
[noexcept]
Returns a read-only (constant) iterator that points to the first element in the deque π¦ Iteration is done in ordinary element order.
Referenced by std::deque< _Tp, _Alloc >::insert(), std::deque< _Tp, _Alloc >::insert(), and std::deque< _Tp, _Alloc >::insert().
π cend [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::deque< _Tp, _Alloc >::cend () const [inline],
[noexcept]
Returns a read-only (constant) iterator that points one past the last element in the deque π Iteration is done in ordinary element order.
π§Ή clear [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::clear () [inline], [noexcept]
Erases all the elements π§Ό
But listen: this function only erases the elements, and if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. Like, you gotta clean up your own mess, bestie ππ
References std::deque< _Tp, _Alloc >::begin().
π crbegin [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::deque< _Tp, _Alloc >::crbegin () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points to the last element in the deque πΈ Iteration is done in reverse element order. Backwards slay π
π crend [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::deque< _Tp, _Alloc >::crend () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points to one before the first element in the deque π¦ Iteration is done in reverse element order.
β¨ emplace
template<typename _Tp , typename _Alloc > template<typename... _Args> deque<
_Tp, _Alloc >::iterator deque::emplace (const_iterator __position, _Args
&&... __args)
Inserts an object in deque before the specified iterator π
__positionβ aconst_iteratorinto the deque.__argsβ arguments.
Returns: an iterator that points to the inserted data π
This function will insert an object of type T constructed with T(std::forward<Args>(args)...) before the specified location. It's giving "build it right there, main character energy" β¨
Referenced by std::deque< _Tp, _Alloc >::insert().
π«§ empty [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> bool
std::deque< _Tp, _Alloc >::empty () const [inline], [noexcept]
Returns true if the deque is empty π (Thus begin() would equal end().) Simple, iconic, does exactly what it says.
π end (const) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_iterator std::deque< _Tp, _Alloc >::end () const [inline],
[noexcept]
Returns a read-only (constant) iterator that points one past the last element in the deque π Iteration is done in ordinary element order.
π end (read/write) [inline], [noexcept]
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::end () [inline], [noexcept]
Returns a read/write iterator that points one past the last element in the deque π Iteration is done in ordinary element order.
Referenced by std::deque< _Tp, _Alloc >::deque(), std::deque< _Tp, _Alloc >::deque(), std::deque< _Tp, _Alloc >::~deque(), std::deque< _Tp, _Alloc >::back(), std::deque< _Tp, _Alloc >::back(), std::operator<=>(), and std::deque< _Tp, _Alloc >::operator=().
erase β the range version βοΈπ
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::erase (const_iterator __first, const_iterator
__last) [inline]
bestie this is the "yeet a whole chunk at once" one. Remove a range of elements, gone, bye. Marked [inline], obviously.
Parameters
__firstβ iterator pointing to the first element to be erased (the start of the vibe removal).__lastβ iterator pointing to one past the last element to be erased. one PAST, ok, classic half-open range energy.
Returns
An iterator pointing to the element pointed to by last prior to erasing (or end()).
This function will erase the elements in the range [__first,__last) and shorten the deque accordingly.
β οΈ the user is cautioned β and like, pay attention bestie β this function only erases the elements. if the elements themselves are pointers, the pointed-to memory is not touched in any way. managing the pointer is the user's responsibility. no cap. π«Ά
erase β the single-element version βοΈπ
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::erase (const_iterator __position) [inline]
Remove element at given position. one (1) element. singular. [inline].
Parameters
__positionβ iterator pointing to the element to be erased.
Returns
An iterator pointing to the next element (or end()).
This function will erase the element at the given position and thus shorten the deque by one. literally minus one, that's the whole bit.
β οΈ same caution as above, and it is not a vibe to skip it: this only erases the element, and if the element is itself a pointer, the pointed-to memory is not touched in any way. managing the pointer is the user's responsibility. π
front β the const one πΈ
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::deque< _Tp, _Alloc >::front () const [inline],
[noexcept]
Returns a read-only (constant) reference to the data at the first element of the deque. like, look, don't touch. [inline] and [noexcept] because she's reliable like that.
References std::deque< _Tp, _Alloc >::begin().
front β the non-const one πΈβ¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> reference
std::deque< _Tp, _Alloc >::front () [inline], [noexcept]
Returns a read/write reference to the data at the first element of the deque. now you can touch. go off. [inline], [noexcept].
References std::deque< _Tp, _Alloc >::begin().
get_allocator π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
allocator_type std::deque< _Tp, _Alloc >::get_allocator () const
[inline], [noexcept]
Get a copy of the memory allocation object. a copy, bestie, not the actual one. [inline], [noexcept].
Referenced by std::deque< _Tp, _Alloc >::operator=().
insert β initializer_list flavour π¦
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::insert (const_iterator __p, initializer_list<
value_type > __l) [inline]
Inserts an initializer list into the deque. curly braces go brrr. [inline].
Parameters
__pβ an iterator into the deque.__lβ aninitializer_list.
Returns
An iterator that points to the inserted data.
This function will insert copies of the data in the initializer_list __l into the deque before the location specified by __p. this is known as list insert. iconique behaviour honestly.
References std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::cbegin().
insert β range flavour π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
template<typename _InputIterator , typename =
std::_RequireInputIter<_InputIterator>> iterator std::deque< _Tp, _Alloc
>::insert (const_iterator __position, _InputIterator __first,
_InputIterator __last) [inline]
Inserts a range into the deque. yes the template signature is long, no we are not scared of it. [inline].
Parameters
__positionβ aconst_iteratorinto the deque.__firstβ an input iterator.__lastβ an input iterator.
Returns
An iterator that points to the inserted data.
This function will insert copies of the data in the range [__first,__last) into the deque before the location specified by __position. this is known as range insert.
References std::__iterator_category(), std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::cbegin().
insert β single value, lvalue flavour π
template<typename _Tp , typename _Alloc > deque< _Tp, _Alloc >::iterator
deque::insert (const_iterator __position, const value_type & __x)
Inserts given value into deque before specified iterator. the classic. the original. the main character.
Parameters
__positionβ aconst_iteratorinto the deque.__xβ data to be inserted.
Returns
An iterator that points to the inserted data.
This function will insert a copy of the given value before the specified location.
insert β n copies flavour β
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::insert (const_iterator __position, size_type
__n, const value_type & __x) [inline]
Inserts a number of copies of given data into the deque. like copy-paste but make it ~~fetch~~ legit. [inline].
Parameters
__positionβ aconst_iteratorinto the deque.__nβ number of elements to be inserted.__xβ data to be inserted.
Returns
An iterator that points to the inserted data.
This function will insert a specified number of copies of the given data before the location specified by __position.
References std::deque< _Tp, _Alloc >::begin(), and std::deque< _Tp, _Alloc >::cbegin().
insert β rvalue flavour π₯
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> iterator
std::deque< _Tp, _Alloc >::insert (const_iterator __position, value_type
&& __x) [inline]
Inserts given rvalue into deque before specified iterator. yes it takes && β she's moving, she's efficient, she ate. [inline].
Parameters
__positionβ aconst_iteratorinto the deque.__xβ data to be inserted.
Returns
An iterator that points to the inserted data.
This function will insert a copy of the given rvalue before the specified location.
References std::deque< _Tp, _Alloc >::emplace(), and std::move().
max_size π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> size_type
std::deque< _Tp, _Alloc >::max_size () const [inline], [noexcept]
Returns the size() of the largest possible deque. that's it. that's the whole function. [inline], [noexcept], unbothered, moisturized, in her lane.
operator= β copy assignment ππ
template<typename _Tp , typename _Alloc > deque< _Tp, _Alloc > &
deque::operator= (const deque< _Tp, _Alloc > & __x)
Deque assignment operator. the copy one.
Parameters
__xβ a deque of identical element and allocator types.
All the elements of x are copied. every single one, bestie.
The newly-created deque uses a copy of the allocator object used by __x (unless the allocator traits dictate a different object). iykyk.
References std::__addressof(), std::deque< _Tp, _Alloc >::begin(), std::deque< _Tp, _Alloc >::end(), std::deque< _Tp, _Alloc >::get_allocator(), std::deque< _Tp, _Alloc >::size(), and std::size().
operator= β move assignment π¦β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> deque &
std::deque< _Tp, _Alloc >::operator= (deque< _Tp, _Alloc > && __x)
[inline], [noexcept]
Deque move assignment operator. [inline], [noexcept] β she is not throwing, she's built different.
Parameters
__xβ a deque of identical element and allocator types.
The contents of __x are moved into this deque (without copying, if the allocators permit it). __x is a valid, but unspecified deque. like she's fine but she's not the same girl anymore, don't ask her questions.
References std::move().
operator= β initializer_list assignment ππ
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> deque &
std::deque< _Tp, _Alloc >::operator= (initializer_list< value_type >
__l) [inline]
Assigns an initializer list to a deque. {a, b, c} and boom, new deque. [inline].
Parameters
__lβ aninitializer_list.
This function fills a deque with copies of the elements in the initializer_list __l.
π
note β the assignment completely changes the deque, and the resulting deque's size() is the same as the number of elements assigned. like a full glow-up, no remnants of before, periodt.
operator[] β the const one πΈπ
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reference std::deque< _Tp, _Alloc >::operator[] (size_type __n)
const [inline], [noexcept]
Subscript access to the data contained in the deque. read-only, look but don't touch. [inline], [noexcept].
Parameters
__nβ the index of the element for which data should be accessed.
Returns
Read-only (constant) reference to data.
This operator allows for easy, array-style, data access. note β data access with this operator is unchecked and out_of_range lookups are not defined. (for checked lookups see at().) π«Ά
operator[] β the non-const one πΈπβ¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> reference
std::deque< _Tp, _Alloc >::operator[] (size_type __n) [inline],
[noexcept]
Subscript access to the data contained in the deque. this one you can write to. [inline], [noexcept].
Parameters
__nβ the index of the element for which data should be accessed.
Returns
Read/write reference to data.
This operator allows for easy, array-style, data access. note β data access with this operator is unchecked and out_of_range lookups are not defined. (for checked lookups see at().) π keep that in mind fr.
pop_back π¬π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::pop_back () [inline], [noexcept]
Removes last element. this is a typical stack operation. it shrinks the deque by one. [inline], [noexcept].
note that no data is returned, and if the last element's data is needed, it should be retrieved before pop_back() is called. like grab the tea before you yeet the cup, bestie. π
References std::deque< _Tp, _Alloc >::_M_pop_back_aux().
pop_front π¬π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::pop_front () [inline], [noexcept]
Removes first element. this is a typical stack operation. it shrinks the deque by one. [inline], [noexcept].
note that no data is returned, and if the first element's data is needed, it should be retrieved before pop_front() is called. same rule, other end. π
References std::deque< _Tp, _Alloc >::_M_pop_front_aux().
push_back π π₯
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::push_back (const value_type & __x) [inline]
Add data to the end of the deque. [inline].
Parameters
__xβ data to be added.
This is a typical stack operation. the function creates an element at the end of the deque and assigns the given data to it. and here's the slay part: due to the nature of a deque this operation can be done in constant time. β‘
References std::deque< _Tp, _Alloc >::_M_push_back_aux().
push_front π π₯π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::push_front (const value_type & __x) [inline]
Add data to the front of the deque. [inline].
Parameters
__xβ data to be added.
This is a typical stack operation. the function creates an element at the front of the deque and assigns the given data to it. due to the nature of a deque this operation can be done in constant time. yes both ends, that's literally the whole point of her. π
References std::deque< _Tp, _Alloc >::_M_push_front_aux().
rbegin β const π¦
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::deque< _Tp, _Alloc >::rbegin () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points to the last element in the deque. iteration is done in reverse element order. yes she goes backwards and she does it flawlessly. [inline], [noexcept].
rbegin β non-const π¦π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reverse_iterator std::deque< _Tp, _Alloc >::rbegin () [inline],
[noexcept]
Returns a read/write reverse iterator that points to the last element in the deque. iteration is done in reverse element order. now you can also write, backwards, in heels. [inline], [noexcept].
rend β const π
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
const_reverse_iterator std::deque< _Tp, _Alloc >::rend () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points to one before the first element in the deque. iteration is done in reverse element order. yes, one before the first β that's not a typo, that's just how reverse iterators coordinate their fit. [inline], [noexcept]. π
β¨ rend() β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>>
reverse_iterator std::deque< _Tp, _Alloc >::rend () [inline], [noexcept]
Ok bestie, reverse-iterator moment π This returns a read/write reverse iterator that points to one before the first element in the deque. Iteration is done in reverse element order. No cap. π¦
β¨ resize() β the one-argument version β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::resize (size_type __new_size) [inline]
Resizes the deque to the specified number of elements. Iconic resize behavior, fr fr.
__new_sizeβ Number of elements the deque should contain.
This function will resize the deque to the specified number of elements. If the number is smaller than the deque's current size, the deque is truncated; otherwise, default constructed elements are appended. References std::deque< _Tp, _Alloc >::size(). π
β¨ resize() β the two-argument version β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::resize (size_type __new_size, const value_type & __x) [inline]
Same resize energy, but now with data to copy into the new spots. Obsessed. π
__new_sizeβ Number of elements the deque should contain.__xβ Data with which new elements should be populated.
This function will resize the deque to the specified number of elements. If the number is smaller than the deque's current size, the deque is truncated; otherwise, the deque is extended and new elements are populated with the given data. References std::deque< _Tp, _Alloc >::size(). π«Ά
β¨ shrink_to_fit() β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::shrink_to_fit () [inline], [noexcept]
A non-binding request to reduce memory use. It's giving "hey bestie, maybe free some space?" β but non-binding, so it's a request, not a promise. π
β¨ size() β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> size_type
std::deque< _Tp, _Alloc >::size () const [inline], [noexcept]
Returns the number of elements in the deque. Simple, clean, main character energy. β
Referenced by std::deque< _Tp, _Alloc >::_M_range_check(), std::operator<=>(), std::deque< _Tp, _Alloc >::operator=(), std::deque< _Tp, _Alloc >::resize(), and std::deque< _Tp, _Alloc >::resize(). Yes, resize() shows up twice in that list β not me double-checking, that's just the original, bestie. π
β¨ swap() β¨
template<typename _Tp , typename _Alloc = std::allocator<_Tp>> void
std::deque< _Tp, _Alloc >::swap (deque< _Tp, _Alloc > & __x) [inline], [noexcept]
Swaps data with another deque. Trade offer: you get my elements, I get yours. π₯
__xβ A deque of the same element and allocator types.
This exchanges the elements between two deques in constant time. (Four pointers, so it should be quite fast.) Note that the global std::swap() function is specialized such that std::swap(d1,d2) will feed to this function. π§
Whether the allocators are swapped depends on the allocator traits. That part is literally doing its own thing, iykyk. π
β¨ Author β¨
Generated automatically by Doxygen for libstdc++ from the source code. π€β¨
That's the whole page, bestie π«Ά Footer source/version + date-line vibes: libstdc++ and std::deque< _Tp, _Alloc >(3cxx). Periodt. π
πΈ
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms