Double-ended sequence stored on Base's heap. More...
#include <StormByte/safe/deque.hxx>
Public Types | |
| using | value_type = T |
| Element type. | |
| using | size_type = Size |
| Element count. Size, not std::size_t. | |
| using | difference_type = std::ptrdiff_t |
| Iterator distance type. | |
| using | reference = T& |
| Mutable element reference. | |
| using | const_reference = const T& |
| Read-only element reference. | |
| using | pointer = T* |
| Mutable element pointer. | |
| using | const_pointer = const T* |
| Read-only element pointer. | |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| Mutable reverse iterator. | |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| Read-only reverse iterator. | |
Public Member Functions | |
| Deque () noexcept | |
| Construct an empty deque. | |
| Deque (size_type count, const T &value) | |
Construct count copies of value. | |
| Deque (size_type count) | |
Construct count value-initialized elements. | |
| template<std::input_iterator InputIt> | |
| Deque (InputIt first, InputIt last) | |
| Copy the range [first, last). | |
| Deque (std::initializer_list< T > values) | |
| Construct from an initializer list. | |
| Deque (const std::deque< T > &values) | |
| Copy a caller-owned STL deque. | |
| STORMBYTE_FORCE_INLINE | Deque (std::deque< T > &&values) |
| Move elements from a caller-owned STL deque and leave it empty. | |
| Deque (const Deque &other) | |
| Copy every element into new Base blocks. | |
| Deque (Deque &&other) noexcept | |
| Take the blocks. | |
| ~Deque () noexcept | |
| Destroy every element and release the blocks. | |
| Deque & | operator= (const Deque &other) |
| Copy-assign. | |
| Deque & | operator= (Deque &&other) noexcept |
| Move-assign. | |
| Deque & | operator= (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| Deque & | operator= (const std::deque< T > &values) |
| Copy-assign a caller-owned STL deque. | |
| STORMBYTE_FORCE_INLINE Deque & | operator= (std::deque< T > &&values) |
| Move-assign elements from a caller-owned STL deque and leave it empty. | |
| void | assign (size_type count, const T &value) |
Replace the contents with count copies of value. | |
| template<std::input_iterator InputIt> | |
| void | assign (InputIt first, InputIt last) |
| Replace the contents with the range [first, last). | |
| void | assign (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| template<std::ranges::input_range R> | |
| void | assign_range (R &&range) |
| Replace the contents with a range. | |
| reference | at (size_type index) |
| Access an element. | |
| const_reference | at (size_type index) const |
| Access an element. | |
| reference | operator[] (size_type index) noexcept |
| Access an element. | |
| const_reference | operator[] (size_type index) const noexcept |
| Access an element. | |
| reference | front () |
| Return the first element. | |
| const_reference | front () const |
| Return the first element. | |
| reference | back () |
| Return the last element. | |
| const_reference | back () const |
| Return the last element. | |
| iterator | begin () noexcept |
| Return a mutable iterator to the first element. | |
| iterator | end () noexcept |
| Return the mutable end iterator. | |
| const_iterator | begin () const noexcept |
| Return a read-only iterator to the first element. | |
| const_iterator | end () const noexcept |
| Return the read-only end iterator. | |
| const_iterator | cbegin () const noexcept |
| Return a read-only iterator to the first element. | |
| const_iterator | cend () const noexcept |
| Return the read-only end iterator. | |
| STORMBYTE_FORCE_INLINE reverse_iterator | rbegin () noexcept |
| Return a mutable reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE reverse_iterator | rend () noexcept |
| Return the mutable reverse end iterator. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | rbegin () const noexcept |
| Return a read-only reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | rend () const noexcept |
| Return the read-only reverse end iterator. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | crbegin () const noexcept |
| Return a read-only reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | crend () const noexcept |
| Return the read-only reverse end iterator. | |
| bool | empty () const noexcept |
| Test whether the deque is empty. | |
| size_type | size () const noexcept |
| Return the element count. | |
| STORMBYTE_FORCE_INLINE size_type | max_size () const noexcept |
| Return the largest representable element count. | |
| void | shrink_to_fit () |
| Release unused blocks. | |
| void | clear () noexcept |
| Destroy every element. | |
| iterator | insert (const_iterator position, const T &value) |
Insert a copy before position. | |
| iterator | insert (const_iterator position, T &&value) |
Insert a moved value before position. | |
| iterator | insert (const_iterator position, size_type count, const T &value) |
Insert count copies before position. | |
| template<std::input_iterator InputIt> | |
| iterator | insert (const_iterator position, InputIt first, InputIt last) |
Insert the range [first, last) before position. | |
| iterator | insert (const_iterator position, std::initializer_list< T > values) |
Insert an initializer list before position. | |
| template<std::ranges::input_range R> | |
| iterator | insert_range (const_iterator position, R &&range) |
Insert a range before position. | |
| template<typename... Args> | |
| iterator | emplace (const_iterator position, Args &&... args) |
Construct an element before position. | |
| iterator | erase (const_iterator position) |
Destroy the element at position. | |
| iterator | erase (const_iterator first, const_iterator last) |
| Destroy the half-open range [first, last). | |
| void | push_back (const T &value) |
| Append a copy. | |
| void | push_back (T &&value) |
| Append a moved value. | |
| template<typename... Args> | |
| reference | emplace_back (Args &&... args) |
| Construct an element at the back. | |
| void | pop_back () |
| Destroy the last element. | |
| void | push_front (const T &value) |
| Prepend a copy. | |
| void | push_front (T &&value) |
| Prepend a moved value. | |
| template<typename... Args> | |
| reference | emplace_front (Args &&... args) |
| Construct an element at the front. | |
| void | pop_front () |
| Destroy the first element. | |
| template<std::ranges::input_range R> | |
| void | append_range (R &&range) |
| Append a range. | |
| template<std::ranges::input_range R> | |
| void | prepend_range (R &&range) |
| Prepend a range. | |
| void | resize (size_type count) |
| Change the element count. | |
| void | resize (size_type count, const T &value) |
| Change the element count. | |
| void | swap (Deque &other) noexcept |
| Exchange blocks. | |
| STORMBYTE_FORCE_INLINE | operator std::deque< T > () const |
| Copy into a caller-owned std::deque. | |
Double-ended sequence stored on Base's heap.
| T | Safe value. |
Not an alias of std::deque. There is no allocator parameter. A move from std::deque copies the elements onto Base's heap and clears the source. It does not steal its buffer. Conversion back is explicit and born in the caller.
| using StormByte::Safe::Deque< T >::const_pointer = const T* |
Read-only element pointer.
| using StormByte::Safe::Deque< T >::const_reference = const T& |
Read-only element reference.
| using StormByte::Safe::Deque< T >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Read-only reverse iterator.
| using StormByte::Safe::Deque< T >::difference_type = std::ptrdiff_t |
Iterator distance type.
| using StormByte::Safe::Deque< T >::pointer = T* |
Mutable element pointer.
| using StormByte::Safe::Deque< T >::reference = T& |
Mutable element reference.
| using StormByte::Safe::Deque< T >::reverse_iterator = std::reverse_iterator<iterator> |
Mutable reverse iterator.
| using StormByte::Safe::Deque< T >::size_type = Size |
Element count. Size, not std::size_t.
| using StormByte::Safe::Deque< T >::value_type = T |
Element type.
|
noexcept |
Construct an empty deque.
| StormByte::Safe::Deque< T >::Deque | ( | size_type | count, |
| const T & | value ) |
Construct count copies of value.
| count | Element count. |
| value | Value to copy. |
| AllocationError | A block could not be allocated. |
|
explicit |
Construct count value-initialized elements.
| count | Element count. |
| AllocationError | A block could not be allocated. |
| StormByte::Safe::Deque< T >::Deque | ( | InputIt | first, |
| InputIt | last ) |
Copy the range [first, last).
| InputIt | Input iterator whose value is convertible to T. |
| first | Start of the source range. |
| last | End of the source range. |
| AllocationError | A block could not be allocated. |
| StormByte::Safe::Deque< T >::Deque | ( | std::initializer_list< T > | values | ) |
Construct from an initializer list.
| values | Initial elements. |
| AllocationError | A block could not be allocated. |
|
explicit |
Copy a caller-owned STL deque.
Its state is unchanged.
| values | Source. |
| AllocationError | A block could not be allocated. |
|
inlineexplicit |
Move elements from a caller-owned STL deque and leave it empty.
| values | Source. Cleared before this function returns. |
| AllocationError | A block could not be allocated. |
| StormByte::Safe::Deque< T >::Deque | ( | const Deque< T > & | other | ) |
Copy every element into new Base blocks.
| other | Source. |
| AllocationError | A block could not be allocated. |
|
noexcept |
Take the blocks.
other is left empty.
| other | Source. |
|
noexcept |
Destroy every element and release the blocks.
| void StormByte::Safe::Deque< T >::append_range | ( | R && | range | ) |
Append a range.
| R | Input range whose value is convertible to T. |
| range | Source range. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::assign | ( | InputIt | first, |
| InputIt | last ) |
Replace the contents with the range [first, last).
| InputIt | Input iterator whose value is convertible to T. |
| first | Start of the source range. |
| last | End of the source range. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::assign | ( | size_type | count, |
| const T & | value ) |
Replace the contents with count copies of value.
| count | Element count. |
| value | Value to copy. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::assign | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | New elements. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::assign_range | ( | R && | range | ) |
Replace the contents with a range.
| R | Input range whose value is convertible to T. |
| range | Source range. |
| AllocationError | A block could not be allocated. |
| reference StormByte::Safe::Deque< T >::at | ( | size_type | index | ) |
Access an element.
| index | Element index. |
| OutOfBoundsError | index is outside the deque. |
| const_reference StormByte::Safe::Deque< T >::at | ( | size_type | index | ) | const |
Access an element.
| index | Element index. |
| OutOfBoundsError | index is outside the deque. |
| reference StormByte::Safe::Deque< T >::back | ( | ) |
Return the last element.
| OutOfBoundsError | The deque is empty. |
| const_reference StormByte::Safe::Deque< T >::back | ( | ) | const |
Return the last element.
| OutOfBoundsError | The deque is empty. |
|
noexcept |
Return a read-only iterator to the first element.
|
noexcept |
Return a mutable iterator to the first element.
|
noexcept |
Return a read-only iterator to the first element.
|
noexcept |
Return the read-only end iterator.
|
noexcept |
Destroy every element.
Capacity is kept.
|
inlinenoexcept |
Return a read-only reverse iterator to the last element.
|
inlinenoexcept |
Return the read-only reverse end iterator.
| iterator StormByte::Safe::Deque< T >::emplace | ( | const_iterator | position, |
| Args &&... | args ) |
Construct an element before position.
| Args | Constructor argument types. |
| position | Insert position. |
| args | Constructor arguments. |
| AllocationError | A block could not be allocated. |
| reference StormByte::Safe::Deque< T >::emplace_back | ( | Args &&... | args | ) |
Construct an element at the back.
| Args | Constructor argument types. |
| args | Constructor arguments. |
| AllocationError | A block could not be allocated. |
| reference StormByte::Safe::Deque< T >::emplace_front | ( | Args &&... | args | ) |
Construct an element at the front.
| Args | Constructor argument types. |
| args | Constructor arguments. |
| AllocationError | A block could not be allocated. |
|
noexcept |
Test whether the deque is empty.
|
noexcept |
Return the read-only end iterator.
|
noexcept |
Return the mutable end iterator.
| iterator StormByte::Safe::Deque< T >::erase | ( | const_iterator | first, |
| const_iterator | last ) |
Destroy the half-open range [first, last).
| first | First element to destroy. |
| last | One past the last element to destroy. |
| iterator StormByte::Safe::Deque< T >::erase | ( | const_iterator | position | ) |
Destroy the element at position.
| position | Element to destroy. |
| reference StormByte::Safe::Deque< T >::front | ( | ) |
Return the first element.
| OutOfBoundsError | The deque is empty. |
| const_reference StormByte::Safe::Deque< T >::front | ( | ) | const |
Return the first element.
| OutOfBoundsError | The deque is empty. |
| iterator StormByte::Safe::Deque< T >::insert | ( | const_iterator | position, |
| const T & | value ) |
Insert a copy before position.
| position | Insert position. |
| value | Value to copy. |
| AllocationError | A block could not be allocated. |
| iterator StormByte::Safe::Deque< T >::insert | ( | const_iterator | position, |
| InputIt | first, | ||
| InputIt | last ) |
Insert the range [first, last) before position.
| InputIt | Input iterator whose value is convertible to T. |
| position | Insert position. |
| first | Start of the source range. |
| last | End of the source range. |
| AllocationError | A block could not be allocated. |
| iterator StormByte::Safe::Deque< T >::insert | ( | const_iterator | position, |
| size_type | count, | ||
| const T & | value ) |
Insert count copies before position.
| position | Insert position. |
| count | Copy count. |
| value | Value to copy. |
position when count is zero. | AllocationError | A block could not be allocated. |
| iterator StormByte::Safe::Deque< T >::insert | ( | const_iterator | position, |
| std::initializer_list< T > | values ) |
Insert an initializer list before position.
| position | Insert position. |
| values | Source elements. |
| AllocationError | A block could not be allocated. |
| iterator StormByte::Safe::Deque< T >::insert | ( | const_iterator | position, |
| T && | value ) |
Insert a moved value before position.
| position | Insert position. |
| value | Value to move. |
| AllocationError | A block could not be allocated. |
| iterator StormByte::Safe::Deque< T >::insert_range | ( | const_iterator | position, |
| R && | range ) |
Insert a range before position.
| R | Input range whose value is convertible to T. |
| position | Insert position. |
| range | Source range. |
| AllocationError | A block could not be allocated. |
|
inlinenoexcept |
Return the largest representable element count.
|
inlineexplicit |
Copy into a caller-owned std::deque.
| Deque & StormByte::Safe::Deque< T >::operator= | ( | const Deque< T > & | other | ) |
Copy-assign.
The previous blocks are released only after the copy exists.
| other | Source. |
| AllocationError | A block could not be allocated. |
| Deque & StormByte::Safe::Deque< T >::operator= | ( | const std::deque< T > & | values | ) |
Copy-assign a caller-owned STL deque.
Its state is unchanged.
| values | Source. |
| AllocationError | A block could not be allocated. |
|
noexcept |
Move-assign.
other is left empty.
| other | Source. |
|
inline |
Move-assign elements from a caller-owned STL deque and leave it empty.
| values | Source. Cleared before this function returns. |
| AllocationError | A block could not be allocated. |
| Deque & StormByte::Safe::Deque< T >::operator= | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | New elements. |
| AllocationError | A block could not be allocated. |
|
noexcept |
Access an element.
| index | Element index. |
|
noexcept |
Access an element.
| index | Element index. |
| void StormByte::Safe::Deque< T >::pop_back | ( | ) |
Destroy the last element.
| void StormByte::Safe::Deque< T >::pop_front | ( | ) |
Destroy the first element.
| void StormByte::Safe::Deque< T >::prepend_range | ( | R && | range | ) |
Prepend a range.
| R | Input range whose value is convertible to T. |
| range | Source range. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::push_back | ( | const T & | value | ) |
Append a copy.
| value | Value to copy. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::push_back | ( | T && | value | ) |
Append a moved value.
| value | Value to move. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::push_front | ( | const T & | value | ) |
Prepend a copy.
| value | Value to copy. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::push_front | ( | T && | value | ) |
Prepend a moved value.
| value | Value to move. |
| AllocationError | A block could not be allocated. |
|
inlinenoexcept |
Return a read-only reverse iterator to the last element.
|
inlinenoexcept |
Return a mutable reverse iterator to the last element.
|
inlinenoexcept |
Return the read-only reverse end iterator.
|
inlinenoexcept |
Return the mutable reverse end iterator.
| void StormByte::Safe::Deque< T >::resize | ( | size_type | count | ) |
Change the element count.
New elements are value-initialized.
| count | New element count. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::resize | ( | size_type | count, |
| const T & | value ) |
Change the element count.
New elements are copies of value.
| count | New element count. |
| value | Value copied into each new element. |
| AllocationError | A block could not be allocated. |
| void StormByte::Safe::Deque< T >::shrink_to_fit | ( | ) |
Release unused blocks.
|
noexcept |
Return the element count.
|
noexcept |