|
From: Jan G. <jan...@us...> - 2007-04-16 23:19:16
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/circular_buffer In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31610/boost/circular_buffer Modified Files: base.hpp space_optimized.hpp Log Message: circular_buffer: updated srcdoc + assign bug fix Index: space_optimized.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/circular_buffer/space_optimized.hpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- space_optimized.hpp 15 Apr 2007 22:52:33 -0000 1.27 +++ space_optimized.hpp 16 Apr 2007 23:19:06 -0000 1.28 @@ -609,7 +609,34 @@ m_capacity_ctrl = capacity_ctrl; } - //! See the circular_buffer source documentation. + //! Assign a copy of the range into the space optimized circular buffer. + /*! + The content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with copies of + elements from the specified range. + \pre Valid range <code>[first, last)</code>.<br> + <code>first</code> and <code>last</code> have to meet the requirements of + <a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>. + \post <code>capacity().%capacity() == std::distance(first, last) \&\& capacity().min_capacity() == 0 \&\& + size() == std::distance(first, last) \&\& (*this)[0]== *first \&\& (*this)[1] == *(first + 1) \&\& ... + \&\& (*this)[std::distance(first, last) - 1] == *(last - 1)</code> + \param first The beginning of the range to be copied. + \param last The end of the range to be copied. + \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is + used). + \throws Whatever <code>T::T(const T&)</code> throws. + \par Exception Safety + Basic. + \par Iterator Invalidation + Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators + equal to end()). + \par Complexity + Linear (in the <code>std::distance(first, last)</code>). + \sa <code>operator=</code>, <code>\link assign(size_type, param_value_type) + assign(size_type, const_reference)\endlink</code>, + <code>\link assign(capacity_type, size_type, param_value_type) + assign(capacity_type, size_type, const_reference)\endlink</code>, + <code>assign(capacity_type, InputIterator, InputIterator)</code> + */ template <class InputIterator> void assign(InputIterator first, InputIterator last) { circular_buffer<T, Alloc>::assign(first, last); @@ -617,7 +644,40 @@ m_capacity_ctrl.m_min_capacity = 0; } - //! See the circular_buffer source documentation. + //! Assign a copy of the range into the space optimized circular buffer specifying the capacity. + /*! + The capacity of the <code>circular_buffer_space_optimized</code> will be set to the specified value and the + content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with copies of + elements from the specified range. + \pre Valid range <code>[first, last)</code>.<br> + <code>first</code> and <code>last</code> have to meet the requirements of + <a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>. + \post <code>capacity() == capacity_ctrl \&\& size() \<= std::distance(first, last) \&\& + (*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\& + (*this)[capacity - 1] == *(last - 1)</code><br><br> + If the number of items to be copied from the range <code>[first, last)</code> is greater than the + specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code> + will be copied.<br><br> The amount of allocated memory will be + <code>max[std::distance(first, last), capacity_ctrl.min_capacity()]</code>. + \param capacity_ctrl The new capacity controller. + \param first The beginning of the range to be copied. + \param last The end of the range to be copied. + \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is + used). + \throws Whatever <code>T::T(const T&)</code> throws. + \par Exception Safety + Basic. + \par Iterator Invalidation + Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators + equal to end()). + \par Complexity + Linear (in the <code>std::distance(first, last)</code>). + \sa <code>operator=</code>, <code>\link assign(size_type, param_value_type) + assign(size_type, const_reference)\endlink</code>, + <code>\link assign(capacity_type, size_type, param_value_type) + assign(capacity_type, size_type, const_reference)\endlink</code>, + <code>assign(InputIterator, InputIterator)</code> + */ template <class InputIterator> void assign(capacity_type capacity_ctrl, InputIterator first, InputIterator last) { m_capacity_ctrl = capacity_ctrl; Index: base.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/circular_buffer/base.hpp,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- base.hpp 15 Apr 2007 22:52:33 -0000 1.85 +++ base.hpp 16 Apr 2007 23:19:06 -0000 1.86 @@ -1184,7 +1184,7 @@ \par Exception Safety Basic. \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code>. + Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to end()). \par Complexity Linear (in the <code>std::distance(first, last)</code>). \sa <code>operator=</code>, <code>\link assign(size_type, param_value_type) @@ -1202,7 +1202,6 @@ /*! The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of the <code>circular_buffer</code> will be removed and replaced with copies of elements from the specified range. - (See the <i>Effect</i>.) \pre Valid range <code>[first, last)</code>.<br> <code>first</code> and <code>last</code> have to meet the requirements of <a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>. @@ -1221,7 +1220,7 @@ \par Exception Safety Basic. \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code>. + Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to end()). \par Complexity Linear (in the <code>std::distance(first, last)</code>). \sa <code>operator=</code>, <code>\link assign(size_type, param_value_type) @@ -2164,7 +2163,7 @@ BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range size_type distance = std::distance(first, last); if (distance > new_capacity) { - std::advance(first, distance - capacity); + std::advance(first, distance - new_capacity); distance = new_capacity; } assign_n(new_capacity, distance, |