diff --git a/doc/circular_buffer.html b/doc/circular_buffer.html index 7cd1eb1..999a2b2 100644 --- a/doc/circular_buffer.html +++ b/doc/circular_buffer.html @@ -1049,7 +1049,7 @@ template <class T, class Alloc> Throws:
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
capacity The maximum number of elements which can be stored in the
circular_buffer.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
Nothing.
circular_buffer).
get_allocator()
+ "#classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098">get_allocator() for
+ obtaining an allocator reference.
Nothing.
circular_buffer).
circular_buffer. If the
- circular_buffer is empty it returns an iterator equal to the one returned by end().
+ circular_buffer is empty it returns an iterator equal to the one returned by
+ end() .
Nothing.
circular_buffer).
end(),
- rbegin()
+ rbegin(),
+ rend()
circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by begin().
+ to the one returned by begin().
Nothing.
circular_buffer).
begin()
+ begin(),
+ rbegin(),
+ rend()
circular_buffer. If
- the circular_buffer is empty it returns an iterator equal to the one returned by end() const.
+ the circular_buffer is empty it returns an iterator equal to the one returned by
+ end()
+ const.
Nothing.
circular_buffer).
end()
+ const, rbegin() const,
+ rend()
const
circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by begin() const.
+ to the one returned by begin() const const.
Nothing.
circular_buffer).
begin()
+ const, rbegin() const,
+ rend()
const
circular_buffer. If
- the circular_buffer is empty it returns an iterator equal to the one returned by rend().
+ the circular_buffer is empty it returns an iterator equal to the one returned by
+ rend().
Nothing.
circular_buffer).
rend(),
- begin()
+ begin(),
+ end()
circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rbegin().
+ to the one returned by rbegin().
Nothing.
circular_buffer).
rbegin()
+ rbegin(),
+ begin(),
+ end()
circular_buffer
. If the circular_buffer is empty it returns an iterator equal to the one returned by
- rend() const.
+ rend()
+ const.
Nothing.
circular_buffer).
rend()
+ const, begin() const,
+ end()
const
circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rbegin() const.
+ to the one returned by rbegin() const.
Nothing.
circular_buffer).
rbegin()
+ const, begin() const,
+ end()
const
index The position of the element.
+ Nothing.
circular_buffer).
at(size_type)
+ at()
index The position of the element.
+ Nothing.
at(size_type)
- const
+ at() const
index position.
+ index The position of the element.
+ index is invalid (when index >= std::out_of_range when the index is invalid (when index >= size()).
circular_buffer).
operator[](size_type)
+ operator[]
index position.
+ index The position of the element.
+ index is invalid (when index >= std::out_of_range when the index is invalid (when index >= size()).
circular_buffer).
operator[](size_type)
+ operator[]
const
Nothing.
circular_buffer).
Nothing.
circular_buffer).
Nothing.
circular_buffer).
Nothing.
circular_buffer).
This method in combination with array_two() can be useful
- when passing the stored data into the legacy C API as an array. Suppose there is a
+ when passing the stored data into a legacy C API as an array. Suppose there is a
circular_buffer of capacity 10, containing 7 characters 'a', 'b', ..., 'g'
where cbuff[0] == 'a', cbuff[1] == 'b', ... and cbuff[6] ==
'g':
@@ -2480,7 +2530,7 @@ template <class T, class Alloc>
Throws:
Nothing.
circular_buffer).
This method in combination with array_one() can be useful
- when passing the stored data into the legacy C API as an array.
+ when passing the stored data into a legacy C API as an array.
Nothing.
circular_buffer).
This method in combination with array_two() const can be
- useful when passing the stored data into the legacy C API as an array.
+ useful when passing the stored data into a legacy C API as an array.
Nothing.
circular_buffer).
array_two()
+ const; array_one() for more
- details.how to pass data into the legacy C API.
+ details.how to pass data into a legacy C API.
This method in combination with array_one() const can be
- useful when passing the stored data into the legacy C API as an array.
+ useful when passing the stored data into a legacy C API as an array.
Nothing.
circular_buffer).
- This method can be useful when passing the stored data into the legacy C API as an array. + This method can be useful when passing the stored data into a legacy C API as an array.
0 if empty.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
array_two() for the
- other option.how to pass data into the legacy C API.
+ other option.how to pass data into a legacy C API.
Nothing.
circular_buffer).
Nothing.
circular_buffer).
size(),
- capacity(),
- resize(),
- set_capacity()
+ capacity()
Nothing.
circular_buffer).
Nothing.
circular_buffer).
Nothing.
circular_buffer).
true then the
- first (leftmost) elements will be removed. If set to false then the last (leftmost)
- elements will be removed.
- circular_buffer.
(*this).capacity() ==
+ capacity() ==
new_capacity
- If the current number of elements stored in the circular buffer is greater than the desired new
- capacity then ((*this).size() - new_capacity)
- elements will be removed according to the remove_front parameter.
+
+ If the current number of elements stored in the circular_buffer is greater than the
+ desired new capacity then number of [size() - new_capacity]
+ first (leftmost) elements will be removed.
+ new_capacity The new capacity.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
circular_buffer). The complexity of the
+ allocator's allocate() and deallocate() methods which are used in
+ set_capacity() is not
+ considered.
+ circular_buffer.
+ rset_capacity(),
+ resize()
true then the
- first (leftmost) elements will be removed. If set to false then the last (rightmost)
- elements will be removed.
- circular_buffer.
(*this).size() ==
+ size() ==
+ new_size && capacity() >=
new_size
- If the new size is greater than the current size, the rest of the circular buffer is filled with copies
- of item. In case the resulting size exceeds the current capacity the capacity is set to
- new_size. If the new size is lower than the current size then ((*this).size() - new_size)
- elements will be removed according to the remove_front parameter.
+
+ If the new size is greater than the current size, copies of item will be inserted at the
+ back of the of the circular_buffer in order to achieve the desired size. In the
+ case the resulting size exceeds the current capacity the capacity will be set to
+ new_size.
+ If the current number of elements stored in the circular_buffer is greater than the
+ desired new size then number of [size() - new_size]
+ last (rightmost) elements will be removed. (The capacity will remain unchanged.)
+ new_size The new size.
+ item The element the circular_buffer will be filled with in order to gain the
+ requested size. (See the postcondition.)
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
circular_buffer). The complexity of the
+ allocator's allocate() and deallocate() methods which are used in
+ set_capacity() is not
+ considered.
+ circular_buffer.
+ rresize(),
+ set_capacity()
circular_buffer.
+ capacity() ==
+ new_capacitycircular_buffer is greater than the
+ desired new capacity then number of [size() - new_capacity]
+ last (rightmost) elements will be removed.
+ new_capacity The new capacity.
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
+ allocator is used).
+ Whatever T::T(const T&) throws.
+ circular_buffer). The complexity of the
+ allocator's allocate() and deallocate() methods which are used in
+ rset_capacity() is not
+ considered.
+ circular_buffer.
+ set_capacity(),
+ rresize()
+ circular_buffer.
+ size() ==
+ new_size && capacity() >=
+ new_sizeitem will be inserted at the
+ front of the of the circular_buffer in order to achieve the desired size. In the
+ case the resulting size exceeds the current capacity the capacity will be set to
+ new_size.circular_buffer is greater than the
+ desired new size then number of [size() - new_size]
+ first (leftmost) elements will be removed. (The capacity will remain unchanged.)
+ new_size The new size.
+ item The element the circular_buffer will be filled with in order to gain the
+ requested size. (See the postcondition.)
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
+ allocator is used).
+ Whatever T::T(const T&) throws.
+ circular_buffer). The complexity of the
+ allocator's allocate() and deallocate() methods which are used in
+ set_capacity() is not
+ considered.
+ circular_buffer.
+ rresize(),
+ set_capacity()
+ std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
std::bad_alloc if the standard
+ An allocation error if memory is exhausted (std::bad_alloc if the standard
allocator is used).
Whatever T::T(const T&) throws.
circular_buffers.
circular_buffer whose content should be swapped.
+ cb The circular_buffer whose content should be swapped.
Nothing.
circular_buffer).
Whatever T::T(const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa get_allocator()
+ \sa get_allocator() for obtaining an allocator %reference.
*/
allocator_type get_allocator() const { return m_alloc; }
@@ -193,7 +193,7 @@ public:
\return A reference to the allocator.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -209,15 +209,16 @@ public:
//! Get the iterator pointing to the beginning of the circular_buffer.
/*!
\return A random access iterator pointing to the first element of the circular_buffer. If the
- circular_buffer is empty it returns an iterator equal to the one returned by end().
+ circular_buffer is empty it returns an iterator equal to the one returned by end()
+ .
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa end(), rbegin()
+ \sa end(), rbegin(), rend()
*/
iterator begin() { return iterator(this, empty() ? 0 : m_first); }
@@ -225,15 +226,15 @@ public:
/*!
\return A random access iterator pointing to the element "one behind" the last element of the
circular_buffer. If the circular_buffer is empty it returns an iterator equal to
- the one returned by begin().
+ the one returned by begin().
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa begin()
+ \sa begin(), rbegin(), rend()
*/
iterator end() { return iterator(this, 0); }
@@ -241,15 +242,15 @@ public:
/*!
\return A const random access iterator pointing to the first element of the circular_buffer. If
the circular_buffer is empty it returns an iterator equal to the one returned by
- end() const.
+ end() const.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa end() const
+ \sa end() const, rbegin() const, rend() const
*/
const_iterator begin() const { return const_iterator(this, empty() ? 0 : m_first); }
@@ -257,15 +258,15 @@ public:
/*!
\return A const random access iterator pointing to the element "one behind" the last element of the
circular_buffer. If the circular_buffer is empty it returns an iterator equal to
- the one returned by begin() const.
+ the one returned by begin() const const.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa begin() const
+ \sa begin() const, rbegin() const, rend() const
*/
const_iterator end() const { return const_iterator(this, 0); }
@@ -273,15 +274,15 @@ public:
/*!
\return A reverse random access iterator pointing to the last element of the circular_buffer.
If the circular_buffer is empty it returns an iterator equal to the one returned by
- rend().
+ rend().
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa rend(), begin()
+ \sa rend(), begin(), end()
*/
reverse_iterator rbegin() { return reverse_iterator(end()); }
@@ -289,15 +290,15 @@ public:
/*!
\return A reverse random access iterator pointing to the element "one before" the first element of the
circular_buffer. If the circular_buffer is empty it returns an iterator equal to the
- one returned by rbegin().
+ one returned by rbegin().
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa rbegin()
+ \sa rbegin(), begin(), end()
*/
reverse_iterator rend() { return reverse_iterator(begin()); }
@@ -305,15 +306,15 @@ public:
/*!
\return A const reverse random access iterator pointing to the last element of the circular_buffer
. If the circular_buffer is empty it returns an iterator equal to the one returned
- by rend() const.
+ by rend() const.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa rend() const
+ \sa rend() const, begin() const, end() const
*/
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
@@ -321,30 +322,31 @@ public:
/*!
\return A const reverse random access iterator pointing to the element "one before" the first element of the
circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rbegin() const.
+ to the one returned by rbegin() const.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa rbegin() const
+ \sa rbegin() const, begin() const, end() const
*/
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
//! Get the element at the index position.
/*!
\pre 0 \<= index \&\& index < size()
+ \param index The position of the element.
\return A reference to the element at the index position.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa at(size_type)
+ \sa at()
*/
reference operator [] (size_type index) {
BOOST_CB_ASSERT(index < size()); // check for invalid index
@@ -354,6 +356,7 @@ public:
//! Get the element at the index position.
/*!
\pre 0 \<= index \&\& index < size()
+ \param index The position of the element.
\return A const reference to the element at the index position.
\throws Nothing.
\par Complexity
@@ -362,7 +365,7 @@ public:
Strong.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa at(size_type) const
+ \sa \link at(size_type)const at() const \endlink
*/
return_value_type operator [] (size_type index) const {
BOOST_CB_ASSERT(index < size()); // check for invalid index
@@ -371,15 +374,16 @@ public:
//! Get the element at the index position.
/*!
+ \param index The position of the element.
\return A const reference to the element at the index position.
\throws std::out_of_range when the index is invalid (when index >= size()).
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
Strong.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa operator[](size_type)
+ \sa operator[]
*/
reference at(size_type index) {
check_position(index);
@@ -388,15 +392,16 @@ public:
//! Get the element at the index position.
/*!
+ \param index The position of the element.
\return A const reference to the element at the index position.
\throws std::out_of_range when the index is invalid (when index >= size()).
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
Strong.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa operator[](size_type) const
+ \sa \link operator[](size_type)const operator[] const \endlink
*/
return_value_type at(size_type index) const {
check_position(index);
@@ -409,7 +414,7 @@ public:
\return A reference to the first element of the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -427,7 +432,7 @@ public:
\return A reference to the last element of the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -445,7 +450,7 @@ public:
\return A const reference to the first element of the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -463,7 +468,7 @@ public:
\return A const reference to the last element of the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -477,8 +482,8 @@ public:
//! Get the first continuos array of the internal buffer.
/*!
- This method in combination with array_two() can be useful when passing the stored data into the
- legacy C API as an array. Suppose there is a circular_buffer of capacity 10, containing 7
+ This method in combination with array_two() can be useful when passing the stored data into
+ a legacy C API as an array. Suppose there is a circular_buffer of capacity 10, containing 7
characters 'a', 'b', ..., 'g' where cbuff[0] == 'a', cbuff[1] == 'b',
... and cbuff[6] == 'g':circular_buffer cbuff(10); circular_buffer is empty the size of the returned array is 0.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -523,14 +528,14 @@ public:
//! Get the second continuos array of the internal buffer.
/*!
- This method in combination with array_one() can be useful when passing the stored data into the
- legacy C API as an array.
+ This method in combination with array_one() can be useful when passing the stored data into
+ a legacy C API as an array.
\return The array range of the second continuos array of the internal buffer. In the case the internal buffer
is linear or the circular_buffer is empty the size of the returned array is
0.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -544,17 +549,17 @@ public:
//! Get the first continuos array of the internal buffer.
/*!
This method in combination with array_two() const can be useful when passing the stored data into
- the legacy C API as an array.
+ a legacy C API as an array.
\return The array range of the first continuos array of the internal buffer. In the case the
circular_buffer is empty the size of the returned array is 0.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa array_one() for more details.how to pass data into the legacy C API.
+ \sa array_two() const; array_one() for more details.how to pass data into a legacy C API.
*/
const_array_range array_one() const {
return const_array_range(m_first, (m_last <= m_first && !empty() ? m_end : m_last) - m_first);
@@ -563,13 +568,13 @@ public:
//! Get the second continuos array of the internal buffer.
/*!
This method in combination with array_one() const can be useful when passing the stored data into
- the legacy C API as an array.
+ a legacy C API as an array.
\return The array range of the second continuos array of the internal buffer. In the case the internal buffer
is linear or the circular_buffer is empty the size of the returned array is
0.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -582,9 +587,9 @@ public:
//! Linearize the internal buffer into a continuous array.
/*!
- This method can be useful when passing the stored data into the legacy C API as an array.
+ This method can be useful when passing the stored data into a legacy C API as an array.
\post \&(*this)[0] \< \&(*this)[1] \< ... \< \&(*this)[size() - 1]
- \return A pointer to the beginning of the array or 0 if empty.
+ \return A pointer to the beginning of the array or 0 if empty.
\throws Whatever T::T(const T&) throws.
\throws Whatever T::operator = (const T&) throws.
\par Complexity
@@ -596,7 +601,7 @@ public:
if the postcondition is already met prior calling this method.
\warning In general invoking any method which modifies the internal state of the circular_buffer
may delinearize the internal buffer and invalidate the returned pointer.
- \sa array_one() and array_two() for the other option.how to pass data into the legacy
+ \sa array_one() and array_two() for the other option.how to pass data into a legacy
C API.
*/
pointer linearize() {
@@ -649,7 +654,7 @@ public:
\return The number of elements stored in the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -663,12 +668,12 @@ public:
\return The maximum size/capacity the circular_buffer can be set to.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterator.
- \sa size(), capacity(), resize(), set_capacity()
+ \sa size(), capacity()
*/
size_type max_size() const {
return std::minfalse otherwise.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -695,7 +700,7 @@ public:
equals the capacity of the circular_buffer; false otherwise.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -709,7 +714,7 @@ public:
\return The maximum number of elements which can be stored in the circular_buffer.
\throws Nothing.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -718,24 +723,25 @@ public:
*/
size_type capacity() const { return m_end - m_buff; }
- //! Change the capacity of the circular buffer.
+ //! Change the capacity of the circular_buffer.
/*!
+ \post capacity() == new_capacitycircular_buffer is greater than the desired
+ new capacity then number of [size() - new_capacity] first (leftmost) elements will be
+ removed.
\param new_capacity The new capacity.
- \param remove_front This parameter plays its role only if the
- current number of elements stored in the circular buffer
- is greater than the desired new capacity. If set to
- true then the first (leftmost) elements
- will be removed. If set to false then the
- last (leftmost) elements will be removed.
- \post (*this).capacity() == new_capacity((*this).size() - new_capacity) elements
- will be removed according to the remove_front
- parameter.
- \throws "An allocation error" if memory is exhausted (std::bad_alloc if the standard allocator is used).
+ \throws "An allocation error" if memory is exhausted (std::bad_alloc if the standard allocator is
+ used).
\throws Whatever T::T(const T&) throws.
- \note For iterator invalidation see the documentation.
+ \par Complexity
+ Linear (in the size/new capacity of the circular_buffer). The complexity of the allocator's
+ %allocate() and %deallocate() methods which are used in set_capacity()
+ is not considered.
+ \par Exception Safety
+ Strong.
+ \par Iterator Invalidation
+ Invalidates all iterators pointing to the circular_buffer.
+ \sa rset_capacity(), resize()
*/
void set_capacity(size_type new_capacity) {
if (new_capacity == capacity())
@@ -750,36 +756,60 @@ public:
BOOST_CATCH_END
}
- //! Change the size of the circular buffer.
+ //! Change the size of the circular_buffer.
/*!
+ \post size() == new_size \&\& capacity() >= new_sizeitem will be inserted at the
+ back of the of the circular_buffer in order to achieve the desired size. In the case
+ the resulting size exceeds the current capacity the capacity will be set to new_size.circular_buffer is greater than the desired
+ new size then number of [size() - new_size] last (rightmost) elements will be
+ removed. (The capacity will remain unchanged.)
\param new_size The new size.
- \param item See the postcondition.
- \param remove_front This parameter plays its role only if the
- current number of elements stored in the circular buffer
- is greater than the desired new capacity. If set to
- true then the first (leftmost) elements
- will be removed. If set to false then the
- last (rightmost) elements will be removed.
- \post (*this).size() == new_sizeitem.
- In case the resulting size exceeds the current capacity
- the capacity is set to new_size.
- If the new size is lower than the current size then
- ((*this).size() - new_size) elements will be removed
- according to the remove_front parameter.
+ \param item The element the circular_buffer will be filled with in order to gain the requested
+ size. (See the postcondition.)
\throws "An allocation error" if memory is exhausted (std::bad_alloc if the standard allocator is used).
\throws Whatever T::T(const T&) throws.
- \note For iterator invalidation see the documentation.
+ \par Complexity
+ Linear (in the size/new capacity of the circular_buffer). The complexity of the allocator's
+ %allocate() and %deallocate() methods which are used in set_capacity()
+ is not considered.
+ \par Exception Safety
+ Strong.
+ \par Iterator Invalidation
+ Invalidates all iterators pointing to the circular_buffer.
+ \sa rresize(), set_capacity()
*/
void resize(size_type new_size, param_value_type item = value_type()) {
- if (new_size > size())
- increase_size(new_size, item);
- else
- erase(begin(), end() - new_size);
+ if (new_size > size()) {
+ if (new_size > capacity())
+ set_capacity(new_size);
+ insert(end(), new_size - size(), item);
+ } else {
+ erase(end() - (size() - new_size), end());
+ }
}
- //! TODO doc
+ //! Change the capacity of the circular_buffer.
+ /*!
+ \post capacity() == new_capacitycircular_buffer is greater than the desired
+ new capacity then number of [size() - new_capacity] last (rightmost) elements will be
+ removed.
+ \param new_capacity The new capacity.
+ \throws "An allocation error" if memory is exhausted (std::bad_alloc if the standard allocator is
+ used).
+ \throws Whatever T::T(const T&) throws.
+ \par Complexity
+ Linear (in the size/new capacity of the circular_buffer). The complexity of the allocator's
+ %allocate() and %deallocate() methods which are used in rset_capacity()
+ is not considered.
+ \par Exception Safety
+ Basic.
+ \par Iterator Invalidation
+ Invalidates all iterators pointing to the circular_buffer.
+ \sa set_capacity(), rresize()
+ */
void rset_capacity(size_type new_capacity) {
if (new_capacity == capacity())
return;
@@ -793,12 +823,38 @@ public:
BOOST_CATCH_END
}
- //! TODO doc
+ //! Change the size of the circular_buffer.
+ /*!
+ \post size() == new_size \&\& capacity() >= new_sizeitem will be inserted at the
+ front of the of the circular_buffer in order to achieve the desired size. In the case
+ the resulting size exceeds the current capacity the capacity will be set to new_size.circular_buffer is greater than the desired
+ new size then number of [size() - new_size] first (leftmost) elements will be
+ removed. (The capacity will remain unchanged.)
+ \param new_size The new size.
+ \param item The element the circular_buffer will be filled with in order to gain the requested
+ size. (See the postcondition.)
+ \throws "An allocation error" if memory is exhausted (std::bad_alloc if the standard allocator is used).
+ \throws Whatever T::T(const T&) throws.
+ \par Complexity
+ Linear (in the size/new capacity of the circular_buffer). The complexity of the allocator's
+ %allocate() and %deallocate() methods which are used in set_capacity()
+ is not considered.
+ \par Exception Safety
+ Strong.
+ \par Iterator Invalidation
+ Invalidates all iterators pointing to the circular_buffer.
+ \sa rresize(), set_capacity()
+ */
void rresize(size_type new_size, param_value_type item = value_type()) {
- if (new_size > size())
- increase_size(new_size, item);
- else
- erase(begin() + new_size, end());
+ if (new_size > size()) {
+ if (new_size > capacity())
+ set_capacity(new_size);
+ insert(begin(), new_size - size(), item);
+ } else {
+ erase(begin(), end() - new_size);
+ }
}
// Construction/Destruction
@@ -997,7 +1053,7 @@ public:
\throws Nothing.
\post this contains elements of cb and vice versa.
\par Complexity
- Constant.
+ Constant (in the size of the circular_buffer).
\par Exception Safety
No-throw.
\par Iterator Invalidation
@@ -1650,13 +1706,6 @@ private:
BOOST_CATCH_END
}
- //! Increase the size of the circular buffer.
- void increase_size(size_type new_size, param_value_type item) {
- if (new_size > capacity())
- set_capacity(new_size);
- insert(end(), new_size - size(), item);
- }
-
//! Reset the circular buffer.
void reset(pointer buff, pointer last, size_type new_capacity) {
destroy();
diff --git a/include/boost/circular_buffer/space_optimized.hpp b/include/boost/circular_buffer/space_optimized.hpp
index 7905432..917424b 100644
--- a/include/boost/circular_buffer/space_optimized.hpp
+++ b/include/boost/circular_buffer/space_optimized.hpp
@@ -169,10 +169,13 @@ public:
//! See the circular_buffer source documentation.
void resize(size_type new_size, param_value_type item = value_type()) {
- if (new_size > size())
- increase_size(new_size, item);
- else
- erase(begin(), end() - new_size);
+ if (new_size > size()) {
+ if (new_size > capacity())
+ m_capacity_ctrl.m_capacity = new_size;
+ insert(end(), new_size - size(), item);
+ } else {
+ erase(end() - (size() - new_size), end());
+ }
}
//! See the circular_buffer source documentation.
@@ -191,10 +194,13 @@ public:
//! See the circular_buffer source documentation.
void rresize(size_type new_size, param_value_type item = value_type()) {
- if (new_size > size())
- increase_size(new_size, item);
- else
- erase(begin() + new_size, end());
+ if (new_size > size()) {
+ if (new_size > capacity())
+ m_capacity_ctrl.m_capacity = new_size;
+ insert(begin(), new_size - size(), item);
+ } else {
+ erase(begin(), end() - new_size);
+ }
}
//! Create an empty space optimized circular buffer with a maximum capacity.
@@ -648,13 +654,6 @@ private:
return std::min(capacity_ctrl.m_capacity, std::max(capacity_ctrl.m_min_capacity, static_cast