General Utility Library for C++14
2.12
|
A variant of SlidingBuffer that exposes the underlying container through its iterator interface.
The direct iterator access to the underlying buffer offers a performance benefit in some cases. However, it comes at the cost of limited flexibility. SlidingBufferExposed behaves identically to SlidingBuffer except for the differences listed here:
ElementT | Type of elements in the buffer |
fixed_capacity | Maximum number of elements in the buffer (i.e. capacity), zero if unspecified/dynamic |
Container | Type of the underlying container, usually not specified |
#include <SlidingBuffer.h>
Inherits SlidingBuffer< ElementT, 0u, typename std::conditional_t<(0u >=1u), std::array< ElementT, 0u >, std::vector< ElementT >> >.
Public Types | |
using | iterator = typename Container::iterator |
Iterator to an element. | |
using | const_iterator = typename Container::const_iterator |
Iterator to a const element. | |
using | reverse_iterator = typename Container::reverse_iterator |
Iterator to an element in reversed container. | |
using | const_reverse_iterator = typename Container::const_reverse_iterator |
Iterator to a const element in reversed container. | |
Public Member Functions | |
auto | begin () noexcept -> iterator |
Return an iterator to the first occupied element of the underlying container. More... | |
auto | begin () const noexcept -> const_iterator |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
auto | cbegin () const noexcept -> const_iterator |
Return a constant iterator to the first occupied element of the underlying container. More... | |
auto | end () noexcept -> iterator |
Return an iterator to the element following the last element in the used space of the underlying container. More... | |
auto | end () const noexcept -> const_iterator |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
auto | cend () const noexcept -> const_iterator |
Return a constant iterator to the element following the last element in the used space of the underlying container. More... | |
auto | rbegin () noexcept -> reverse_iterator |
Return a reverse iterator to the first used element of the reversed underlying container. More... | |
auto | crbegin () const noexcept -> const_reverse_iterator |
Return a constant reverse iterator to the first used element of the reversed underlying container. More... | |
auto | rend () noexcept -> reverse_iterator |
Return an iterator to the last element of the reversed underlying container. More... | |
auto | crend () const noexcept -> const_reverse_iterator |
Return a constant iterator to the last element of the reversed underlying container. More... | |
auto | resize (size_type new_capacity, ShrinkBehavior shrink_behavior=ShrinkBehavior::keep_front_elements) -> void |
Resize the container. More... | |
auto | reserve (size_type size, ShrinkBehavior shrink_behavior=ShrinkBehavior::keep_front_elements) -> void |
Resize the container (identical to resize()). More... | |
|
inlinenoexcept |
Return an iterator to the first occupied element of the underlying container.
The iterator accesses the underlying container in its native order. If the elements are stored in contiguous fashion (if only push_back() or only push_front() were used to add them), begin() returns an iterator pointing to the first occupied element. If the elements are non-contiguous (which can happen if push_front() and push_back() were mixed and the buffer is not yet full), begin() simply points to the start of the container and the range [begin(), end()] may enclose default-constructed elements.
If the container is empty, the returned iterator is equal to end().
|
inlinenoexcept |
Return a constant iterator to the first occupied element of the underlying container.
|
inlinenoexcept |
Return a constant iterator to the element following the last element in the used space of the underlying container.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Return an iterator to the element following the last element in the used space of the underlying container.
If the container is empty, the returned iterator is equal to begin().
This element acts as a placeholder; attempting to access it results in undefined behavior.
The iterator accesses the underlying container in its native order. If the elements are stored in contiguous fashion (if only push_back() or only push_front() were used to add them), end() returns an iterator pointing past the last occupied element. If the elements are non-contiguous (which can happen if push_front() and push_back() were mixed and the buffer is not yet full), end() simply points past the last element of the container and the range [begin(), end()] may enclose default-constructed elements.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
Resize the container.
Only possible if the underlying container is a std::vector.
shrink_behavior
.new_capacity | New capacity (maximum size) of the sliding buffer. |
shrink_behavior | Specify the ShrinkBehavior. |
shrink_behavior
(ShrinkBehavior::keep_front_elements) is transparent only if exclusively push_front() was used to add elements. If push_back() was used, resize() without a second argument discards the most recent elements; in these cases, make sure to specify ShrinkBehavior::keep_back_elements.