![]() |
Home | Libraries | People | FAQ | More |
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 { public: // types typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef circular_buffer< ; typedef ; // construct/copy/destruct ( = ) ; (, = ); (, , = ); (, , , = ); (circular_buffer_space_optimized< ); (circular_buffer_space_optimized< ) ; template<typename InputIterator> (, , = ); template<typename InputIterator> (, , , = ); circular_buffer_space_optimized< (circular_buffer_space_optimized< ); circular_buffer_space_optimized< (circular_buffer_space_optimized< ) ; // public member functions () ; () ; () ; (); (, = ); (); (, = ); (, ); (, , ); template<typename InputIterator> (, ); template<typename InputIterator> (, , ); (circular_buffer_space_optimized< ) ; (); (); (); (); (); (); (); (); (, ); (, ); (); (, , ); template<typename InputIterator> (, , ); (, ); (, ); (); (, , ); template<typename InputIterator> (, , ); (); (, ); (); (, ); (); };
circular_buffer_space_optimized
public
typesCapacity 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
construct/copy/destruct( alloc = ) ;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. |
( capacity_ctrl, alloc = );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). |
( capacity_ctrl, item, alloc = );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 (std::bad_alloc if the standard allocator is used). T::T(const T&) throws. |
( capacity_ctrl, n, item, alloc = );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< 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< cb) ;The move constructor.
Move constructs a
from circular_buffer_space_optimized
cb
, leaving cb
empty.
Constant.
Parameters: |
|
||
Requires: |
C++ compiler with rvalue references support. |
||
Postconditions: |
|
||
Throws: |
Nothing. |
template<typename InputIterator> ( first, last, alloc = );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> ( capacity_ctrl, first, last, alloc = );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< (circular_buffer_space_optimized< cb);The assign operator.
Makes this
to become a copy of the specified circular_buffer_space_optimized
.
circular_buffer_space_optimized
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to this
(except iterators equal to circular_buffer_space_optimized
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 (std::bad_alloc if the standard allocator is used). T::T(const T&) throws. |
circular_buffer_space_optimized< (circular_buffer_space_optimized< cb) ;Move assigns content of
cb
to *this
, leaving cb
empty.
Complexity. Constant.
Parameters: |
|
||
Requires: |
C++ compiler with rvalue references support. |
||
Postconditions: |
|
||
Throws: |
Nothing. |
circular_buffer_space_optimized
public member functions() ;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. |
() ;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. |
() ;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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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. |
( new_size, item = );Change the size of the
circular_buffer_space_optimized
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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. |
( new_size, item = );Change the size of the
circular_buffer_space_optimized
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( n, item);Assign
n
items into the space optimized circular buffer. The content of the
will be removed and replaced with circular_buffer_space_optimized
n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( capacity_ctrl, n, item);Assign
n
items into the space optimized circular buffer specifying the capacity. The capacity of the
will be set to the specified value and the content of the circular_buffer_space_optimized
will be removed and replaced with circular_buffer_space_optimized
n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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> ( first, last);Assign a copy of the range into the space optimized circular buffer.
The content of the
will be removed and replaced with copies of elements from the specified range.
circular_buffer_space_optimized
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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> ( capacity_ctrl, first, last);Assign a copy of the range into the space optimized circular buffer specifying the capacity.
The capacity of the
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.
circular_buffer_space_optimized
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
(circular_buffer_space_optimized< cb) ;Swap the contents of two space-optimized circular-buffers.
Exception Safety. No-throw.
Iterator Invalidation. Invalidates all iterators of both
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.) circular_buffer_space_optimized
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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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). |
();Insert a new element at the end of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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. |
( 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
(except iterators equal to circular_buffer_space_optimized
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. |
();Insert a new element at the beginning of the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
();Remove the last element from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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). |
();Remove the first element from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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). |
( pos, item);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos, item);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos);Insert an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos, n, item);Insert
n
copies of the item
at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
end()
).
Complexity. Linear (in min[capacity().capacity(), size() + n]
).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer_space_optimized
|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> ( pos, first, last);Insert the range
[first, last)
at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer_space_optimized
|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. |
( pos, item);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos, item);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos);Insert an element before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos, n, item);Insert
n
copies of the item
before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
end()
).
Complexity. Linear (in min[capacity().capacity(), size() + n]
).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer_space_optimized
|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> ( pos, first, last);Insert the range
[first, last)
before the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer_space_optimized
|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. |
( pos);Remove an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( first, last);Erase the range
[first, last)
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( pos);Remove an element at the specified position.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
( first, last);Erase the range
[first, last)
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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. |
();Remove all stored elements from the space optimized circular buffer.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer_space_optimized
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). |