Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType > Class Template Reference
Inheritance diagram for pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >:
pw::containers::internal::GenericDequeBase< CountAndCapacityType > pw::DynamicDeque< T, uint16_t > pw::DynamicDeque< T, size_type > pw::DynamicDeque< Packet > pw::DynamicDeque< Packet, size_type > pw::DynamicDeque< ValueType, SizeType >

Public Types

using value_type = ValueType
 
using size_type = typename CountAndCapacityType::size_type
 
using difference_type = ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using iterator = containers::internal::DequeIterator< Derived >
 
using const_iterator = containers::internal::DequeIterator< const Derived >
 
- Public Types inherited from pw::containers::internal::GenericDequeBase< CountAndCapacityType >
using size_type = typename CountAndCapacityType::size_type
 

Public Member Functions

 GenericDeque (const GenericDeque &)=delete
 
 GenericDeque (GenericDeque &&)=delete
 
GenericDequeoperator= (const GenericDeque &)=delete
 
GenericDeque && operator= (GenericDeque &&)=delete
 
void assign (size_type count, const value_type &value)
 Sets the contents to count copies of value. Crashes if cannot fit.
 
template<typename It , int & ..., typename = containers::internal::EnableIfInputIterator<It>>
void assign (It start, It finish)
 
void assign (const std::initializer_list< value_type > &list)
 Sets contents to copies of the items from the list. Crashes if cannot fit.
 
constexpr reference at (size_type index)
 
constexpr const_reference at (size_type index) const
 
constexpr reference operator[] (size_type index)
 
constexpr const_reference operator[] (size_type index) const
 
constexpr reference front ()
 
constexpr const_reference front () const
 
constexpr reference back ()
 
constexpr const_reference back () const
 
constexpr std::pair< span< const value_type >, span< const value_type > > contiguous_data () const
 Provides access to the valid data in a contiguous form.
 
constexpr std::pair< span< value_type >, span< value_type > > contiguous_data ()
 
constexpr iterator begin () noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator cend () const noexcept
 
void clear ()
 
iterator erase (const_iterator pos)
 Erases the item at pos, which must be a dereferenceable iterator.
 
iterator erase (const_iterator first, const_iterator last)
 
void push_back (const value_type &value)
 
void push_back (value_type &&value)
 
template<typename... Args>
void emplace_back (Args &&... args)
 
void pop_back ()
 
void push_front (const value_type &value)
 
void push_front (value_type &&value)
 
template<typename... Args>
void emplace_front (Args &&... args)
 
void pop_front ()
 
template<typename... Args>
iterator emplace (const_iterator pos, Args &&... args)
 
iterator insert (const_iterator pos, const value_type &value)
 
iterator insert (const_iterator pos, value_type &&value)
 
iterator insert (const_iterator pos, size_type count, const value_type &value)
 
template<typename InputIt , typename = containers::internal::EnableIfInputIterator<InputIt>>
iterator insert (const_iterator pos, InputIt first, InputIt last)
 
iterator insert (const_iterator pos, std::initializer_list< value_type > ilist)
 
void resize (size_type new_size)
 
void resize (size_type new_size, const value_type &value)
 
template<typename... Args>
std::optional< typename GenericDeque< Derived, ValueType, CountAndCapacityType >::iterator > try_emplace (const_iterator pos, Args &&... args)
 
template<typename ForwardIt , typename >
std::optional< typename GenericDeque< Derived, ValueType, CountAndCapacityType >::iterator > try_insert (const_iterator pos, ForwardIt first, ForwardIt last)
 
constexpr size_type capacity () const noexcept
 Returns the maximum number of elements in the deque.
 
constexpr bool empty () const noexcept
 
constexpr size_type size () const noexcept
 Returns the number of elements in the deque.
 
- Public Member Functions inherited from pw::containers::internal::GenericDequeBase< CountAndCapacityType >
constexpr bool empty () const noexcept
 
constexpr size_type size () const noexcept
 Returns the number of elements in the deque.
 
constexpr size_type capacity () const noexcept
 Returns the maximum number of elements in the deque.
 

Protected Member Functions

constexpr GenericDeque (size_type initial_capacity) noexcept
 
Derived & operator= (const std::initializer_list< value_type > &list)
 
template<typename T , typename = containers::internal::EnableIfIterable<T>>
Derived & operator= (const T &other)
 
bool try_assign (size_type count, const value_type &value)
 
template<typename It , int & ..., typename = containers::internal::EnableIfForwardIterator<It>>
bool try_assign (It start, It finish)
 
bool try_assign (const std::initializer_list< value_type > &list)
 
template<typename... Args>
std::optional< iterator > try_emplace (const_iterator pos, Args &&... args)
 
std::optional< iterator > try_insert (const_iterator pos, const value_type &value)
 
std::optional< iterator > try_insert (const_iterator pos, value_type &&value)
 
std::optional< iterator > try_insert (const_iterator pos, size_type count, const value_type &value)
 
template<typename ForwardIt , typename = containers::internal::EnableIfForwardIterator<ForwardIt>>
std::optional< iterator > try_insert (const_iterator pos, ForwardIt first, ForwardIt last)
 
std::optional< iterator > try_insert (const_iterator pos, std::initializer_list< value_type > ilist)
 
bool try_push_back (const value_type &value)
 
bool try_push_back (value_type &&value)
 
template<typename... Args>
bool try_emplace_back (Args &&... args)
 
bool try_push_front (const value_type &value)
 
bool try_push_front (value_type &&value)
 
template<typename... Args>
bool try_emplace_front (Args &&... args)
 
bool try_resize (size_type new_size)
 
bool try_resize (size_type new_size, const value_type &value)
 
- Protected Member Functions inherited from pw::containers::internal::GenericDequeBase< CountAndCapacityType >
CountAndCapacityType & count_and_capacity () noexcept
 
constexpr void MoveAssignIndices (GenericDequeBase &other) noexcept
 
void SwapIndices (GenericDequeBase &other) noexcept
 
bool CanExtendBuffer () const
 
bool CanShrinkBuffer () const
 
void HandleNewBuffer (size_type new_capacity)
 
void HandleExtendedBuffer (size_type new_capacity)
 
void HandleShrunkBuffer (size_type new_capacity)
 

Detailed Description

template<typename Derived, typename ValueType, typename CountAndCapacityType>
class pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >

Generic array-based deque class.

Uses CRTP to access the underlying array and handle potentially resizing it. Extended by pw::InlineDeque and pw::DynamicDeque.

Member Function Documentation

◆ assign()

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename It , int & ..., typename >
void pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::assign ( It  start,
It  finish 
)

Sets the contents to copies of the items from the iterator. Crashes if cannot fit.

◆ emplace()

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename... Args>
iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::emplace ( const_iterator  pos,
Args &&...  args 
)
inline

Constructs an item in place at pos. Crashes if memory allocation fails.

Returns
an iterator to the emplaced item.

◆ erase()

template<typename Derived , typename ValueType , typename CountAndCapacityType >
GenericDeque< Derived, ValueType, CountAndCapacityType >::iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::erase ( const_iterator  first,
const_iterator  last 
)

Erases the items in the range [first, last). Does nothing if first == last.

◆ insert() [1/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::insert ( const_iterator  pos,
const value_type &  value 
)
inline

Inserts a copy of an item at pos. Crashes if memory allocation fails.

Returns
an iterator to the inserted item.

◆ insert() [2/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename InputIt , typename >
GenericDeque< Derived, ValueType, CountAndCapacityType >::iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::insert ( const_iterator  pos,
InputIt  first,
InputIt  last 
)

Inserts the contents of an iterator at pos. Crashes if memory allocation fails.

Returns
an iterator to the first inserted item.

◆ insert() [3/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::insert ( const_iterator  pos,
size_type  count,
const value_type &  value 
)
inline

Inserts count copies of value at pos. Crashes if memory allocation fails.

Returns
an iterator to the first inserted item.

◆ insert() [4/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::insert ( const_iterator  pos,
std::initializer_list< value_type >  ilist 
)
inline

Inserts an initializer list at pos. Crashes if memory allocation fails.

Returns
an iterator to the first inserted item.

◆ insert() [5/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
iterator pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::insert ( const_iterator  pos,
value_type &&  value 
)
inline

Inserts an item at pos using move semanatics. Crashes if memory allocation fails.

Returns
an iterator to the inserted item.

◆ try_assign() [1/3]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
bool pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_assign ( const std::initializer_list< value_type > &  list)
inlineprotected

Replaces the container with copies of items from an initializer list. Does nothing if unable to accommodate all items.

◆ try_assign() [2/3]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename It , int & ..., typename >
bool pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_assign ( It  start,
It  finish 
)
protected

Replaces the container with copies of items from an iterator. Does nothing if unable to accommodate all items.

try_assign() requires a forward iterator so that the capacity can be checked upfront to avoid partial assignments. Input iterators are only suitable for one pass, so could be exhausted by a std::distance check.

◆ try_assign() [3/3]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
bool pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_assign ( size_type  count,
const value_type &  value 
)
protected

Attempts to replace the contents with count copies of value. If count <blockquote>&zwj;capacity() and allocation is supported, attempts to allocate to

increase capacity. Does nothing if unable to accommodate count items.

◆ try_emplace()

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename... Args>
std::optional< iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_emplace ( const_iterator  pos,
Args &&...  args 
)
protected

Tries to construct an item in place at pos.

Returns
an std::optional iterator to the emplaced item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

◆ try_insert() [1/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
std::optional< iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_insert ( const_iterator  pos,
const value_type &  value 
)
inlineprotected

Tries to insert a copy of an item at pos.

Returns
an std::optional iterator to the inserted item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

◆ try_insert() [2/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
template<typename ForwardIt , typename = containers::internal::EnableIfForwardIterator<ForwardIt>>
std::optional< iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_insert ( const_iterator  pos,
ForwardIt  first,
ForwardIt  last 
)
protected

Tries to insert the contents of an iterator at pos.

Returns
an std::optional iterator to the first inserted item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

◆ try_insert() [3/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
std::optional< typename GenericDeque< Derived, ValueType, CountAndCapacityType >::iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_insert ( const_iterator  pos,
size_type  count,
const value_type &  value 
)
protected

Tries to insert count copies of value at pos.

Returns
an std::optional iterator to the first inserted item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

◆ try_insert() [4/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
std::optional< iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_insert ( const_iterator  pos,
std::initializer_list< value_type >  ilist 
)
inlineprotected

Tries to insert an initializer list at pos.

Returns
an std::optional iterator to the first inserted item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

◆ try_insert() [5/5]

template<typename Derived , typename ValueType , typename CountAndCapacityType >
std::optional< iterator > pw::containers::internal::GenericDeque< Derived, ValueType, CountAndCapacityType >::try_insert ( const_iterator  pos,
value_type &&  value 
)
inlineprotected

Tries to insert an item at pos using move semanatics.

Returns
an std::optional iterator to the inserted item. If memory allocation fails, returns std::nullopt and the container is left unchanged.

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