From 1280b36f7653fd52ae116499ea54f83c9958a4a3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 3 Feb 2008 10:35:18 +0000 Subject: [PATCH] Merge. [SVN r43063] --- doc/circular_buffer.html | 52 +++++++++++++++---- doc/space_optimized.html | 22 ++++++++ include/boost/circular_buffer/base.hpp | 10 +++- include/boost/circular_buffer/details.hpp | 2 +- .../boost/circular_buffer/space_optimized.hpp | 5 ++ test/base_test.cpp | 1 - test/common.ipp | 4 ++ 7 files changed, 83 insertions(+), 13 deletions(-) diff --git a/doc/circular_buffer.html b/doc/circular_buffer.html index f12fb5a..319d6ef 100644 --- a/doc/circular_buffer.html +++ b/doc/circular_buffer.html @@ -30,6 +30,11 @@ Introductory Example
Synopsis
Rationale
+ - Thread-Safety
+ - Overwrite Operation
+ - Writing to a Full Buffer
+ - Reading/Removing from an Empty Buffer
+ - Iterator Invalidation
Caveats
Debug Support
More Examples
@@ -366,9 +371,10 @@ template <class T, class Alloc>

The thread-safety of the circular_buffer is the same as the thread-safety of containers in most STL - implementations. This means the circular_buffer is thread-safe only in the sense that simultaneous - accesses to distinct instances of the circular_buffer are safe, and simultaneous read accesses to a - shared circular_buffer are safe. + implementations. This means the circular_buffer is not thread-safe. The thread-safety is + guarantied only in the sense that simultaneous accesses to distinct instances of the + circular_buffer are safe, and simultaneous read accesses to a shared circular_buffer + are safe.

If multiple threads access a single circular_buffer, and at least one of the threads may potentially @@ -378,7 +384,7 @@ template <class T, class Alloc> Buffer Example.)

- Overwrite Operation + Overwrite Operation

Overwrite operation occurs when an element is inserted into a full circular_buffer - the old element @@ -397,7 +403,7 @@ template <class T, class Alloc> being shifted (e.g. as a result of insertion into the middle of container).

- Writing to a Full Buffer + Writing to a Full Buffer

There are several options how to cope with the case if a data source produces more data than can fit in the @@ -429,7 +435,7 @@ template <class T, class Alloc> contrary to std::vector, it bears an overhead for its circular behaviour.

- Reading/Removing from an Empty Buffer + Reading/Removing from an Empty Buffer

When reading or removing an element from an empty buffer, the buffer should be able to notify the data consumer @@ -450,7 +456,7 @@ template <class T, class Alloc> which throws an exception when the index is out of range.

- Iterator Invalidation + Iterator Invalidation

An iterator is usually considered to be invalidated if an element, the iterator pointed to, had been removed or @@ -933,11 +939,11 @@ template <class T, class Alloc>

- Note: + Warning:
This constructor has been defined only due to compatibility with the STL container definition. Avoid - using it because it may allocate very large amount of memory. + using it because it may allocate very large amount of memory.
@@ -5984,6 +5990,19 @@ template <class T, class Alloc> "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin(), pos)). +
+
+ Note: +
+
+ This method is symetric to the erase(iterator) method + and is more effective than erase(iterator) if the + iterator pos is close to the beginning of the circular_buffer. (See the + Complexity.) +
+
See Also: @@ -6095,6 +6114,21 @@ template <class T, class Alloc> "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin(), last)).
+
+
+ Note: +
+
+ This method is symetric to the erase(iterator, + iterator) method and is more effective than erase(iterator, + iterator) if std::distance(begin(), first) is lower + that std::distance(last, end()). +
+
See Also: diff --git a/doc/space_optimized.html b/doc/space_optimized.html index eb57654..c000a43 100644 --- a/doc/space_optimized.html +++ b/doc/space_optimized.html @@ -3920,6 +3920,17 @@ public: Linear (in the size of the circular_buffer_space_optimized).
+
+
+ Note: +
+
+ Basically there is no difference between erase(iterator) + and this method. It is implemented only for consistency with the base circular_buffer. +
+
See Also: @@ -4041,6 +4052,17 @@ public: Linear (in the size of the circular_buffer_space_optimized).
+
+
+ Note: +
+
+ Basically there is no difference between erase(iterator, + iterator) and this method. It is implemented only for consistency with the base + circular_buffer. +
+
See Also: diff --git a/include/boost/circular_buffer/base.hpp b/include/boost/circular_buffer/base.hpp index 1d09685..8c371a8 100644 --- a/include/boost/circular_buffer/base.hpp +++ b/include/boost/circular_buffer/base.hpp @@ -909,8 +909,8 @@ public: used). \par Complexity Constant. - \note This constructor has been defined only due to compatibility with the STL container definition. Avoid - using it because it may allocate very large amount of memory. + \warning This constructor has been defined only due to compatibility with the STL container definition. Avoid + using it because it may allocate very large amount of memory. */ explicit circular_buffer(const allocator_type& alloc = allocator_type()) : m_size(0), m_alloc(alloc) { @@ -1781,6 +1781,9 @@ public: the erased element (towards the beginning). \par Complexity Linear (in std::distance(begin(), pos)). + \note This method is symetric to the erase(iterator) method and is more effective than + erase(iterator) if the iterator pos is close to the beginning of the + circular_buffer. (See the Complexity.) \sa erase(iterator), erase(iterator, iterator), rerase(iterator, iterator), clear() */ @@ -1818,6 +1821,9 @@ public: the erased range (towards the beginning). \par Complexity Linear (in std::distance(begin(), last)). + \note This method is symetric to the erase(iterator, iterator) method and is more effective than + erase(iterator, iterator) if std::distance(begin(), first) is lower that + std::distance(last, end()). \sa erase(iterator), erase(iterator, iterator), rerase(iterator), clear() */ diff --git a/include/boost/circular_buffer/details.hpp b/include/boost/circular_buffer/details.hpp index b47fbca..f9f5b2e 100644 --- a/include/boost/circular_buffer/details.hpp +++ b/include/boost/circular_buffer/details.hpp @@ -227,7 +227,7 @@ public: //! Difference type. typedef typename base_iterator::difference_type difference_type; -#if !defined(BOOST_CB_TEST) && !BOOST_CB_ENABLE_DEBUG +#if !defined(BOOST_CB_TEST) && BOOST_CB_ENABLE_DEBUG == 0 private: #endif // Member variables diff --git a/include/boost/circular_buffer/space_optimized.hpp b/include/boost/circular_buffer/space_optimized.hpp index 6ba6800..b8950cb 100644 --- a/include/boost/circular_buffer/space_optimized.hpp +++ b/include/boost/circular_buffer/space_optimized.hpp @@ -1141,6 +1141,8 @@ public: equal to end()). \par Complexity Linear (in the size of the circular_buffer_space_optimized). + \note Basically there is no difference between erase(iterator) and this method. It is implemented + only for consistency with the base circular_buffer. \sa erase(iterator), erase(iterator, iterator), rerase(iterator, iterator), clear() */ @@ -1171,6 +1173,9 @@ public: equal to end()). \par Complexity Linear (in the size of the circular_buffer_space_optimized). + \note Basically there is no difference between erase(iterator, iterator) and this method. It is + implemented only for consistency with the base + circular_buffer. \sa erase(iterator), erase(iterator, iterator), rerase(iterator), clear() */ diff --git a/test/base_test.cpp b/test/base_test.cpp index 5386137..439d7f7 100644 --- a/test/base_test.cpp +++ b/test/base_test.cpp @@ -189,7 +189,6 @@ void iterator_comparison_test() { BOOST_CHECK(!(end - 1 < it)); } -// TODO add insert, push_back etc. void iterator_invalidation_test() { #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG) diff --git a/test/common.ipp b/test/common.ipp index 8b248d9..d3403f7 100644 --- a/test/common.ipp +++ b/test/common.ipp @@ -534,9 +534,11 @@ void capacity_and_reserve_test() { BOOST_CHECK(cb1.reserve() == 0); BOOST_CHECK(cb1.full()); BOOST_CHECK(cb1.empty()); + BOOST_CHECK(cb1.reserve() == cb1.capacity() - cb1.size()); BOOST_CHECK(cb2.capacity() == 10); BOOST_CHECK(cb2.size() == 0); BOOST_CHECK(cb2.reserve() == 10); + BOOST_CHECK(cb2.reserve() == cb2.capacity() - cb2.size()); cb1.push_back(1); cb2.push_back(2); @@ -548,9 +550,11 @@ void capacity_and_reserve_test() { BOOST_CHECK(cb1.reserve() == 0); BOOST_CHECK(cb1.full()); BOOST_CHECK(cb1.empty()); + BOOST_CHECK(cb1.reserve() == cb1.capacity() - cb1.size()); BOOST_CHECK(cb2.capacity() == 10); BOOST_CHECK(cb2.size() == 3); BOOST_CHECK(cb2.reserve() == 7); + BOOST_CHECK(cb2.reserve() == cb2.capacity() - cb2.size()); generic_test(cb1); generic_test(cb2);