...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::circular_buffer_space_optimized — Space optimized circular buffer container adaptor. T
must be a copyable class or must have an noexcept move constructor and move assignment operator.
// In header: <boost/circular_buffer/space_optimized.hpp> template<typename T, typename Alloc> class circular_buffer_space_optimized : private boost::circular_buffer< T, Alloc > { public: // types typedef circular_buffer< T, Alloc >::value_type value_type; typedef circular_buffer< T, Alloc >::pointer pointer; typedef circular_buffer< T, Alloc >::const_pointer const_pointer; typedef circular_buffer< T, Alloc >::reference reference; typedef circular_buffer< T, Alloc >::const_reference const_reference; typedef circular_buffer< T, Alloc >::size_type size_type; typedef circular_buffer< T, Alloc >::difference_type difference_type; typedef circular_buffer< T, Alloc >::allocator_type allocator_type; typedef circular_buffer< T, Alloc >::const_iterator const_iterator; typedef circular_buffer< T, Alloc >::iterator iterator; typedef circular_buffer< T, Alloc >::const_reverse_iterator const_reverse_iterator; typedef circular_buffer< T, Alloc >::reverse_iterator reverse_iterator; typedef circular_buffer< T, Alloc >::array_range array_range; typedef circular_buffer< T, Alloc >::const_array_range const_array_range; typedef circular_buffer< T, Alloc >::param_value_type param_value_type; typedef circular_buffer< T, Alloc >::rvalue_type rvalue_type; typedef cb_details::capacity_control< size_type > capacity_type; // public member functions bool full() const noexcept; size_type reserve() const noexcept; const capacity_type & capacity() const noexcept; void set_capacity(const capacity_type &); void resize(size_type, param_value_type = value_type()); void rset_capacity(const capacity_type &); void rresize(size_type, param_value_type = value_type()); explicit circular_buffer_space_optimized(const allocator_type & = allocator_type()) noexcept; explicit circular_buffer_space_optimized(capacity_type, const allocator_type & = allocator_type()); circular_buffer_space_optimized(capacity_type, param_value_type, const allocator_type & = allocator_type()); circular_buffer_space_optimized(capacity_type, size_type, param_value_type, const allocator_type & = allocator_type()); circular_buffer_space_optimized(const circular_buffer_space_optimized< T, Alloc > &); circular_buffer_space_optimized(circular_buffer_space_optimized< T, Alloc > &&) noexcept; template<typename InputIterator> circular_buffer_space_optimized(InputIterator, InputIterator, const allocator_type & = allocator_type()); template<typename InputIterator> circular_buffer_space_optimized(capacity_type, InputIterator, InputIterator, const allocator_type & = allocator_type()); circular_buffer_space_optimized< T, Alloc > & operator=(const circular_buffer_space_optimized< T, Alloc > &); circular_buffer_space_optimized< T, Alloc > & operator=(circular_buffer_space_optimized< T, Alloc > &&) noexcept; void assign(size_type, param_value_type); void assign(capacity_type, size_type, param_value_type); template<typename InputIterator> void assign(InputIterator, InputIterator); template<typename InputIterator> void assign(capacity_type, InputIterator, InputIterator); void swap(circular_buffer_space_optimized< T, Alloc > &) noexcept; void push_back(param_value_type); void push_back(rvalue_type); void push_back(); void push_front(param_value_type); void push_front(rvalue_type); void push_front(); void pop_back(); void pop_front(); iterator insert(iterator, param_value_type); iterator insert(iterator, rvalue_type); iterator insert(iterator); void insert(iterator, size_type, param_value_type); template<typename InputIterator> void insert(iterator, InputIterator, InputIterator); iterator rinsert(iterator, param_value_type); iterator rinsert(iterator, rvalue_type); iterator rinsert(iterator); void rinsert(iterator, size_type, param_value_type); template<typename InputIterator> void rinsert(iterator, InputIterator, InputIterator); iterator erase(iterator); iterator erase(iterator, iterator); iterator rerase(iterator); iterator rerase(iterator, iterator); void clear(); };
circular_buffer_space_optimized
public
typestypedef cb_details::capacity_control< size_type > capacity_type;
Capacity controller of the space optimized circular buffer.
See Also: capacity_control in details.hpp.
class capacity_control
{
size_type m_capacity; // Available capacity.
size_type m_min_capacity; // Minimum capacity.
public:
capacity_control(size_type capacity, size_type min_capacity = 0)
: m_capacity(capacity), m_min_capacity(min_capacity)
{};
size_type capacity() const { return m_capacity; }
size_type min_capacity() const { return m_min_capacity; }
operator size_type() const { return m_capacity; }
};
Always capacity >= min_capacity
.
The capacity()
represents the capacity of the circular_buffer_space_optimized
and the min_capacity()
determines the minimal allocated size of its internal buffer.
The converting constructor of the capacity_control
allows implicit conversion from size_type
-like types which ensures compatibility of creating an instance of the circular_buffer_space_optimized
with other STL containers.
On the other hand the operator size_type()
provides implicit conversion to the size_type
which allows to treat the capacity of the circular_buffer_space_optimized
the same way as in the circular_buffer
.
circular_buffer_space_optimized
public member functionsbool full() const noexcept;Is the
circular_buffer_space_optimized
full?
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the circular_buffer_space_optimized
).
See Also: empty()
Returns: |
|
Throws: |
Nothing. |
size_type reserve() const noexcept;Get the maximum number of elements which can be inserted into the
circular_buffer_space_optimized
without overwriting any of already stored elements.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the circular_buffer_space_optimized
).
See Also: capacity()
, size()
, max_size()
Returns: |
|
Throws: |
Nothing. |
const capacity_type & capacity() const noexcept;Get the capacity of the
circular_buffer_space_optimized
.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the circular_buffer_space_optimized
).
See Also: reserve()
, size()
, max_size()
, set_capacity(const capacity_type&)
Returns: |
The capacity controller representing the maximum number of elements which can be stored in the |
Throws: |
Nothing. |
void set_capacity(const capacity_type & capacity_ctrl);Change the capacity (and the minimal guaranteed amount of allocated memory) of the
circular_buffer_space_optimized
.
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in min[size(), capacity_ctrl.capacity()]
).
Note | |
---|---|
To explicitly clear the extra allocated memory use the shrink-to-fit technique: |
See Also: rset_capacity(const capacity_type&)
, resize(size_type, const_reference)
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
An allocation error if memory is exhausted, (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void resize(size_type new_size, param_value_type item = value_type());Change the size of the
circular_buffer_space_optimized
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the new size of the circular_buffer_space_optimized
).
See Also: rresize(size_type, const_reference)
, set_capacity(const capacity_type&)
Parameters: |
|
||||
Postconditions: |
|
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void rset_capacity(const capacity_type & capacity_ctrl);Change the capacity (and the minimal guaranteed amount of allocated memory) of the
circular_buffer_space_optimized
.
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in min[size(), capacity_ctrl.capacity()]
).
See Also: set_capacity(const capacity_type&)
, rresize(size_type, const_reference)
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void rresize(size_type new_size, param_value_type item = value_type());Change the size of the
circular_buffer_space_optimized
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the new size of the circular_buffer_space_optimized
).
See Also: resize(size_type, const_reference)
, rset_capacity(const capacity_type&)
Parameters: |
|
||||
Postconditions: |
|
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
explicit circular_buffer_space_optimized(const allocator_type & alloc = allocator_type()) noexcept;Create an empty space optimized circular buffer with zero capacity.
Complexity. Constant.
Warning | |
---|---|
Since Boost version 1.36 the behaviour of this constructor has changed. Now it creates a space optimized circular buffer with zero capacity. |
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
Nothing. |
explicit circular_buffer_space_optimized(capacity_type capacity_ctrl, const allocator_type & alloc = allocator_type());Create an empty space optimized circular buffer with the specified capacity.
Complexity. Constant.
Parameters: |
|
||||
Postconditions: |
|
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |
circular_buffer_space_optimized(capacity_type capacity_ctrl, param_value_type item, const allocator_type & alloc = allocator_type());Create a full space optimized circular buffer with the specified capacity filled with
capacity_ctrl.capacity()
copies of item
.
Complexity. Linear (in the capacity_ctrl.capacity()
).
Parameters: |
|
||||||
Postconditions: |
|
||||||
Throws: |
An allocation error if memory is exhausted ( Whatever |
circular_buffer_space_optimized(capacity_type capacity_ctrl, size_type n, param_value_type item, const allocator_type & alloc = allocator_type());Create a space optimized circular buffer with the specified capacity filled with
n
copies of item
.
Complexity. Linear (in the n
).
Parameters: |
|
||||||||
Requires: |
|
||||||||
Postconditions: |
|
||||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer_space_optimized(const circular_buffer_space_optimized< T, Alloc > & cb);The copy constructor.
Creates a copy of the specified circular_buffer_space_optimized
.
Complexity. Linear (in the size of cb
).
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer_space_optimized(circular_buffer_space_optimized< T, Alloc > && cb) noexcept;The move constructor.
Move constructs a circular_buffer_space_optimized
from cb
, leaving cb
empty.
Constant.
Parameters: |
|
||
Requires: |
C++ compiler with rvalue references support. |
||
Postconditions: |
|
||
Throws: |
Nothing. |
template<typename InputIterator> circular_buffer_space_optimized(InputIterator first, InputIterator last, const allocator_type & alloc = allocator_type());Create a full space optimized circular buffer filled with a copy of the range.
Complexity. Linear (in the std::distance(first, last)
).
Parameters: |
|
||||||
Requires: |
Valid range |
||||||
Postconditions: |
|
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept and InputIterator is a move iterator. |
template<typename InputIterator> circular_buffer_space_optimized(capacity_type capacity_ctrl, InputIterator first, InputIterator last, const allocator_type & alloc = allocator_type());Create a space optimized circular buffer with the specified capacity (and the minimal guaranteed amount of allocated memory) filled with a copy of the range.
Complexity. Linear (in std::distance(first, last)
; in min[capacity_ctrl.capacity(), std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
Parameters: |
|
||||||||
Requires: |
Valid range |
||||||||
Postconditions: |
|
||||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer_space_optimized< T, Alloc > & operator=(const circular_buffer_space_optimized< T, Alloc > & cb);The assign operator.
Makes this circular_buffer_space_optimized
to become a copy of the specified circular_buffer_space_optimized
.
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to this circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of cb
).
See Also: assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
An allocation error if memory is exhausted ( Whatever |
circular_buffer_space_optimized< T, Alloc > & operator=(circular_buffer_space_optimized< T, Alloc > && cb) noexcept;Move assigns content of
cb
to *this
, leaving cb
empty.
Complexity. Constant.
Parameters: |
|
||
Requires: |
C++ compiler with rvalue references support. |
||
Postconditions: |
|
||
Throws: |
Nothing. |
void assign(size_type n, param_value_type item);Assign
n
items into the space optimized circular buffer. The content of the circular_buffer_space_optimized
will be removed and replaced with n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the n
).
See Also: operator=
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
|
||||
Postconditions: |
|
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void assign(capacity_type capacity_ctrl, size_type n, param_value_type item);Assign
n
items into the space optimized circular buffer specifying the capacity. The capacity of the circular_buffer_space_optimized
will be set to the specified value and the content of the circular_buffer_space_optimized
will be removed and replaced with n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the n
).
See Also: operator=
, assign(size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
|
||||||
Postconditions: |
|
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
template<typename InputIterator> void assign(InputIterator first, InputIterator last);Assign a copy of the range into the space optimized circular buffer.
The content of the circular_buffer_space_optimized
will be removed and replaced with copies of elements from the specified range.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the std::distance(first, last)
).
See Also: operator=
, assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
|
||||
Requires: |
Valid range |
||||
Postconditions: |
|
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept and InputIterator is a move iterator. |
template<typename InputIterator> void assign(capacity_type capacity_ctrl, InputIterator first, InputIterator last);Assign a copy of the range into the space optimized circular buffer specifying the capacity.
The capacity of the circular_buffer_space_optimized
will be set to the specified value and the content of the circular_buffer_space_optimized
will be removed and replaced with copies of elements from the specified range.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in std::distance(first, last)
; in min[capacity_ctrl.capacity(), std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
See Also: operator=
, assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
Valid range |
||||||
Postconditions: |
|
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept and InputIterator is a move iterator. |
void swap(circular_buffer_space_optimized< T, Alloc > & cb) noexcept;Swap the contents of two space-optimized circular-buffers.
Exception Safety. No-throw.
Iterator Invalidation. Invalidates all iterators of both circular_buffer_space_optimized
containers. (On the other hand the iterators still point to the same elements but within another container. If you want to rely on this feature you have to turn the __debug_support off, otherwise an assertion will report an error if such invalidated iterator is used.)
Complexity. Constant (in the size of the circular_buffer_space_optimized
).
See Also: swap(circular_buffer<T, Alloc>&, circular_buffer<T, Alloc>&)
, swap(circular_buffer_space_optimized<T, Alloc>&, circular_buffer_space_optimized<T, Alloc>&)
Parameters: |
|
||
Postconditions: |
|
||
Throws: |
Nothing. |
void push_back(param_value_type item);Insert a new element at the end of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_front(const_reference)
, pop_back()
, pop_front()
Parameters: |
|
||
Postconditions: |
if |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void push_back(rvalue_type item);Insert a new element at the end of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_front(const_reference)
, pop_back()
, pop_front()
Parameters: |
|
||
Postconditions: |
if |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |
void push_back();Insert a new element at the end of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_front(const_reference)
, pop_back()
, pop_front()
Postconditions: |
if |
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T() throws. Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void push_front(param_value_type item);Insert a new element at the beginning of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_back(const_reference)
, pop_back()
, pop_front()
Parameters: |
|
||
Postconditions: |
if |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void push_front(rvalue_type item);Insert a new element at the beginning of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_back(const_reference)
, pop_back()
, pop_front()
Parameters: |
|
||
Postconditions: |
if |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void push_front();Insert a new element at the beginning of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: push_back(const_reference)
, pop_back()
, pop_front()
Postconditions: |
if |
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T() throws. Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void pop_back();Remove the last element from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: pop_front()
, push_back(const_reference)
, push_front(const_reference)
Requires: |
|
Postconditions: |
The last element is removed from the |
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |
void pop_front();Remove the first element from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: pop_back()
, push_back(const_reference)
, push_front(const_reference)
Requires: |
|
Postconditions: |
The first element is removed from the |
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |
iterator insert(iterator pos, param_value_type item);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||
Requires: |
|
||||
Postconditions: |
The |
||||
Returns: |
Iterator to the inserted element or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
iterator insert(iterator pos, rvalue_type item);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||
Requires: |
|
||||
Postconditions: |
The |
||||
Returns: |
Iterator to the inserted element or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
iterator insert(iterator pos);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Parameters: |
|
||
Requires: |
|
||
Postconditions: |
The |
||
Returns: |
Iterator to the inserted element or |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T() throws. Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void insert(iterator pos, size_type n, param_value_type item);Insert
n
copies of the item
at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in min[capacity().capacity(), size() + n]
).
Example. Consider a circular_buffer_space_optimized
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.
|1|2|3|4| | |
p ___^
After inserting 5 elements at the position p
:
insert(p, (size_t)5, 0);
actually only 4 elements get inserted and elements 1
and 2
are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:
|0|0|0|0|3|4|
For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|
.
See Also: insert(iterator, value_type)
, insert(iterator, InputIterator, InputIterator)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
|
||||||
Postconditions: |
The number of |
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
template<typename InputIterator> void insert(iterator pos, InputIterator first, InputIterator last);Insert the range
[first, last)
at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in [size() + std::distance(first, last)]
; in min[capacity().capacity(), size() + std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
Example. Consider a circular_buffer_space_optimized
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.
|1|2|3|4| | |
p ___^
After inserting a range of elements at the position p
:
int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);
actually only elements 6
, 7
, 8
and 9
from the specified range get inserted and elements 1
and 2
are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:
|6|7|8|9|3|4|
For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|
.
See Also: insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
|
||||||
Postconditions: |
Elements from the range |
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
iterator rinsert(iterator pos, param_value_type item);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||
Requires: |
|
||||
Postconditions: |
The |
||||
Returns: |
Iterator to the inserted element or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
iterator rinsert(iterator pos, rvalue_type item);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||
Requires: |
|
||||
Postconditions: |
The |
||||
Returns: |
Iterator to the inserted element or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
iterator rinsert(iterator pos);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Parameters: |
|
||
Requires: |
|
||
Postconditions: |
The |
||
Returns: |
Iterator to the inserted element or |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T() throws. Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
void rinsert(iterator pos, size_type n, param_value_type item);Insert
n
copies of the item
before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in min[capacity().capacity(), size() + n]
).
Example. Consider a circular_buffer_space_optimized
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.
|1|2|3|4| | |
p ___^
After inserting 5 elements before the position p
:
rinsert(p, (size_t)5, 0);
actually only 4 elements get inserted and elements 3
and 4
are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:
|1|2|0|0|0|0|
For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|
.
See Also: rinsert(iterator, value_type)
, rinsert(iterator, InputIterator, InputIterator)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
|
||||||
Postconditions: |
The number of |
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
template<typename InputIterator> void rinsert(iterator pos, InputIterator first, InputIterator last);Insert the range
[first, last)
before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in [size() + std::distance(first, last)]
; in min[capacity().capacity(), size() + std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
Example. Consider a circular_buffer_space_optimized
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.
|1|2|3|4| | |
p ___^
After inserting a range of elements before the position p
:
int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);
actually only elements 5
, 6
, 7
and 8
from the specified range get inserted and elements 3
and 4
are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:
|1|2|5|6|7|8|
For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|
.
See Also: rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Parameters: |
|
||||||
Requires: |
|
||||||
Postconditions: |
Elements from the range |
||||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
iterator erase(iterator pos);Remove an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, clear()
Parameters: |
|
||
Requires: |
|
||
Postconditions: |
The element at the position |
||
Returns: |
Iterator to the first element remaining beyond the removed element or |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::operator = (const T&) throws or nothing if T::operator = (T&&) is noexcept. |
iterator erase(iterator first, iterator last);Erase the range
[first, last)
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: erase(iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, clear()
Parameters: |
|
||||
Requires: |
Valid range |
||||
Postconditions: |
The elements from the range |
||||
Returns: |
Iterator to the first element remaining beyond the removed elements or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::operator = (const T&) throws or nothing if T::operator = (T&&) is noexcept. |
iterator rerase(iterator pos);Remove an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
Note | |
---|---|
Basically there is no difference between |
See Also: erase(iterator)
, erase(iterator, iterator)
, rerase(iterator, iterator)
, clear()
Parameters: |
|
||
Requires: |
|
||
Postconditions: |
The element at the position |
||
Returns: |
Iterator to the first element remaining in front of the removed element or |
||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::operator = (const T&) throws or nothing if T::operator = (T&&) is noexcept. |
iterator rerase(iterator first, iterator last);Erase the range
[first, last)
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
Note | |
---|---|
Basically there is no difference between |
See Also: erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, clear()
Parameters: |
|
||||
Requires: |
Valid range |
||||
Postconditions: |
The elements from the range |
||||
Returns: |
Iterator to the first element remaining in front of the removed elements or |
||||
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::operator = (const T&) throws or nothing if T::operator = (T&&) is noexcept. |
void clear();Remove all stored elements from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the circular_buffer_space_optimized
(except iterators equal to end()
).
Complexity. Linear (in the size of the circular_buffer_space_optimized
).
See Also: ~circular_buffer_space_optimized()
, erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
Postconditions: |
|
Throws: |
An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |