mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 09:02:12 +00:00
Compare commits
1 Commits
boost-1.41
...
boost-1.39
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6afc30f6d |
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# This file was automatically generated from the original CMakeLists.txt file
|
||||
# Add a variable to hold the headers for the library
|
||||
set (lib_headers
|
||||
circular_buffer.hpp
|
||||
circular_buffer_fwd.hpp
|
||||
circular_buffer
|
||||
)
|
||||
|
||||
# Add a library target to the build system
|
||||
boost_library_project(
|
||||
circular_buffer
|
||||
# SRCDIRS
|
||||
TESTDIRS test
|
||||
HEADERS ${lib_headers}
|
||||
# DOCDIRS
|
||||
DESCRIPTION "STL compliant container also known as ring or cyclic buffer."
|
||||
MODULARIZED
|
||||
AUTHORS "Jan Gaspar <jano_gaspar -at- yahoo.com>"
|
||||
# MAINTAINERS
|
||||
)
|
||||
|
||||
|
||||
@@ -238,11 +238,11 @@ public:
|
||||
explicit <a href=
|
||||
"#classboost_1_1circular__buffer_1e53e744d2f94a2bcbfcdb219a9d93300">circular_buffer</a>(const allocator_type& alloc = allocator_type());
|
||||
explicit <a href=
|
||||
"#classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6">circular_buffer</a>(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type());
|
||||
"#classboost_1_1circular__buffer_1862a64cbc6a49376ecbb8321c3b44974">circular_buffer</a>(capacity_type capacity, const allocator_type& alloc = allocator_type());
|
||||
<a href=
|
||||
"#classboost_1_1circular__buffer_1fdace8f110d5b7a17c02020757f06fe8">circular_buffer</a>(size_type n, const_reference item, const allocator_type& alloc = allocator_type());
|
||||
<a href=
|
||||
"#classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230">circular_buffer</a>(capacity_type buffer_capacity, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
|
||||
"#classboost_1_1circular__buffer_10c7e9286d8270357d7e369b183124239">circular_buffer</a>(capacity_type capacity, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
|
||||
<a href=
|
||||
"#classboost_1_1circular__buffer_1e515d8a951eeb18b8cc930300e7e13bd">circular_buffer</a>(const circular_buffer<T, Alloc>& cb);
|
||||
template <class InputIterator>
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
"#classboost_1_1circular__buffer_1744ec06b06a5a723386b645a29cb8ed2">circular_buffer</a>(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
|
||||
template <class InputIterator>
|
||||
<a href=
|
||||
"#classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f">circular_buffer</a>(capacity_type buffer_capacity, InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
|
||||
"#classboost_1_1circular__buffer_1a64dcad327971194a706d52487151eb7">circular_buffer</a>(capacity_type capacity, InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
|
||||
<a href="#classboost_1_1circular__buffer_164250ffbbbdbc62b99e8301fc195b80c">~circular_buffer</a>();
|
||||
|
||||
allocator_type <a href=
|
||||
@@ -303,13 +303,13 @@ public:
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign</a>(size_type n, const_reference item);
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign</a>(capacity_type buffer_capacity, size_type n, const_reference item);
|
||||
"#classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca">assign</a>(capacity_type capacity, size_type n, const_reference item);
|
||||
template <class InputIterator>
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign</a>(InputIterator first, InputIterator last);
|
||||
template <class InputIterator>
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign</a>(capacity_type buffer_capacity, InputIterator first, InputIterator last);
|
||||
"#classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6">assign</a>(capacity_type capacity, InputIterator first, InputIterator last);
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer_1270ab7074c365663a6f18808024fd88b">swap</a>(circular_buffer<T, Alloc>& cb);
|
||||
void <a href=
|
||||
@@ -667,7 +667,6 @@ template <class T, class Alloc>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
@@ -678,13 +677,10 @@ template <class T, class Alloc>
|
||||
typedef boost::circular_buffer<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(boost::call_traits<value_type>::param_type item) {
|
||||
// param_type represents the "best" way to pass a parameter of type value_type to a method
|
||||
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -716,9 +712,8 @@ template <class T, class Alloc>
|
||||
};
|
||||
</pre>
|
||||
<p>
|
||||
The <code>bounded_buffer</code> relies on <a href="../../thread/doc/">Boost Threads</a> and <a href=
|
||||
"../../bind/bind.html">Boost Bind</a> libraries and <a href="../../utility/call_traits.htm">Boost call_traits</a>
|
||||
utility.
|
||||
The <code>bounded_buffer</code> uses <a href="../../thread/doc/">Boost Threads</a> and <a href=
|
||||
"../../bind/bind.html">Boost Bind</a> libraries.
|
||||
</p>
|
||||
<p>
|
||||
The <code>push_front()</code> method is called by the producer thread in order to insert a new item into the
|
||||
@@ -749,8 +744,8 @@ template <class T, class Alloc>
|
||||
For comparison of bounded buffers based on different containers compile and run <a href=
|
||||
"../test/bounded_buffer_comparison.cpp">bounded_buffer_comparison.cpp</a>. The test should reveal the bounded
|
||||
buffer based on the <code>circular_buffer</code> is most effective closely followed by the
|
||||
<code>std::deque</code> based bounded buffer. (In reality the result may differ sometimes because the test is
|
||||
always affected by external factors such as immediate CPU load.)
|
||||
<code>std::deque</code> based bounded buffer. (In praxis the result may be different because the test is affected
|
||||
by external factors such as immediate CPU load.)
|
||||
</p>
|
||||
<h2>
|
||||
<a name="header" id="header">Header Files</a>
|
||||
@@ -1074,7 +1069,7 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6">circular_buffer(capacity_type,
|
||||
"#classboost_1_1circular__buffer_1862a64cbc6a49376ecbb8321c3b44974">circular_buffer(capacity_type,
|
||||
const allocator_type& alloc)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>
|
||||
</dd>
|
||||
@@ -1083,12 +1078,12 @@ template <class T, class Alloc>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6" name=
|
||||
"classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6"></a><code><b>explicit
|
||||
<a id="classboost_1_1circular__buffer_1862a64cbc6a49376ecbb8321c3b44974" name=
|
||||
"classboost_1_1circular__buffer_1862a64cbc6a49376ecbb8321c3b44974"></a><code><b>explicit
|
||||
circular_buffer(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
|
||||
const <a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>&
|
||||
alloc = allocator_type());</b></code><br>
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity, const
|
||||
<a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
|
||||
allocator_type());</b></code><br>
|
||||
<br>
|
||||
Create an empty <code>circular_buffer</code> with the specified capacity.
|
||||
<dl>
|
||||
@@ -1097,7 +1092,7 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
|
||||
buffer_capacity && <a href=
|
||||
capacity && <a href=
|
||||
"#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == 0</code>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1108,7 +1103,7 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<dl compact>
|
||||
<dt>
|
||||
<code>buffer_capacity</code>
|
||||
<code>capacity</code>
|
||||
</dt>
|
||||
<dd>
|
||||
The maximum number of elements which can be stored in the <code>circular_buffer</code>.
|
||||
@@ -1226,10 +1221,10 @@ template <class T, class Alloc>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230" name=
|
||||
"classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230"></a><code><b>circular_buffer(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
|
||||
<a href="#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
|
||||
<a id="classboost_1_1circular__buffer_10c7e9286d8270357d7e369b183124239" name=
|
||||
"classboost_1_1circular__buffer_10c7e9286d8270357d7e369b183124239"></a><code><b>circular_buffer(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity, <a href=
|
||||
"#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
|
||||
"#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item, const
|
||||
<a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
|
||||
allocator_type());</b></code><br>
|
||||
@@ -1241,7 +1236,7 @@ template <class T, class Alloc>
|
||||
<b>Precondition:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code>buffer_capacity >= n</code>
|
||||
<code>capacity >= n</code>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -1250,7 +1245,7 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
|
||||
buffer_capacity && <a href=
|
||||
capacity && <a href=
|
||||
"#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n &&
|
||||
(*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] ==
|
||||
item</code>
|
||||
@@ -1263,7 +1258,7 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<dl compact>
|
||||
<dt>
|
||||
<code>buffer_capacity</code>
|
||||
<code>capacity</code>
|
||||
</dt>
|
||||
<dd>
|
||||
The capacity of the created <code>circular_buffer</code>.
|
||||
@@ -1469,11 +1464,11 @@ template <class T, class Alloc>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f" name=
|
||||
"classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f"></a> <code><b>template <class
|
||||
<a id="classboost_1_1circular__buffer_1a64dcad327971194a706d52487151eb7" name=
|
||||
"classboost_1_1circular__buffer_1a64dcad327971194a706d52487151eb7"></a> <code><b>template <class
|
||||
InputIterator><br>
|
||||
circular_buffer(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity,
|
||||
InputIterator first, InputIterator last, const <a href=
|
||||
"#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
|
||||
allocator_type());</b></code><br>
|
||||
@@ -1495,15 +1490,14 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
|
||||
buffer_capacity && <a href=
|
||||
capacity && <a href=
|
||||
"#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
|
||||
std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] ==
|
||||
*(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last -
|
||||
1)</code><br>
|
||||
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>buffer_capacity</code> then only elements from the range <code>[last - buffer_capacity,
|
||||
last)</code> will be copied.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -1513,7 +1507,7 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<dl compact>
|
||||
<dt>
|
||||
<code>buffer_capacity</code>
|
||||
<code>capacity</code>
|
||||
</dt>
|
||||
<dd>
|
||||
The capacity of the created <code>circular_buffer</code>.
|
||||
@@ -2497,7 +2491,7 @@ template <class T, class Alloc>
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd">operator[]</a></code>
|
||||
<code>operator[]</code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -3426,7 +3420,7 @@ template <class T, class Alloc>
|
||||
<b>Complexity:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>(std::min)(m, n)</code>); constant if the <code>circular_buffer</code> is full.
|
||||
Linear (in <code>std::min(m, n)</code>); constant if the <code>circular_buffer</code> is full.
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -4280,11 +4274,11 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
|
||||
"#classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca">assign(capacity_type, size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
|
||||
InputIterator)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
|
||||
"#classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6">assign(capacity_type,
|
||||
InputIterator, InputIterator)</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -4381,12 +4375,12 @@ template <class T, class Alloc>
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
|
||||
<code><a href="#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type,
|
||||
size_type, const_reference)</a></code>, <code><a href=
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca">assign(capacity_type, size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
|
||||
InputIterator)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
|
||||
"#classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6">assign(capacity_type,
|
||||
InputIterator, InputIterator)</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -4394,10 +4388,10 @@ template <class T, class Alloc>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a" name=
|
||||
"classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a"></a><code><b>void assign(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
|
||||
<a href="#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
|
||||
<a id="classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca" name=
|
||||
"classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca"></a><code><b>void assign(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity, <a href=
|
||||
"#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
|
||||
"#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>
|
||||
item);</b></code><br>
|
||||
<br>
|
||||
@@ -4421,7 +4415,7 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
|
||||
buffer_capacity && <a href=
|
||||
capacity && <a href=
|
||||
"#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n &&
|
||||
(*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] ==
|
||||
item</code>
|
||||
@@ -4434,7 +4428,7 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<dl compact>
|
||||
<dt>
|
||||
<code>buffer_capacity</code>
|
||||
<code>capacity</code>
|
||||
</dt>
|
||||
<dd>
|
||||
The new capacity.
|
||||
@@ -4504,12 +4498,12 @@ template <class T, class Alloc>
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
|
||||
<code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
|
||||
InputIterator)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
|
||||
"#classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6">assign(capacity_type,
|
||||
InputIterator, InputIterator)</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -4616,12 +4610,12 @@ template <class T, class Alloc>
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
|
||||
<code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
|
||||
"#classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca">assign(capacity_type, size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
|
||||
"#classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6">assign(capacity_type,
|
||||
InputIterator, InputIterator)</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -4629,11 +4623,11 @@ template <class T, class Alloc>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366" name=
|
||||
"classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366"></a> <code><b>template <class
|
||||
<a id="classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6" name=
|
||||
"classboost_1_1circular__buffer_11edb80acdf1f7f1df8217d57256e41f6"></a> <code><b>template <class
|
||||
InputIterator><br>
|
||||
void assign(<a href=
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
|
||||
"#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity,
|
||||
InputIterator first, InputIterator last);</b></code><br>
|
||||
<br>
|
||||
Assign a copy of the range into the <code>circular_buffer</code> specifying the capacity.
|
||||
@@ -4658,15 +4652,14 @@ template <class T, class Alloc>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
|
||||
buffer_capacity && <a href=
|
||||
capacity && <a href=
|
||||
"#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
|
||||
std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] ==
|
||||
*(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last -
|
||||
1)</code><br>
|
||||
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>buffer_capacity</code> then only elements from the range <code>[last - buffer_capacity,
|
||||
last)</code> will be copied.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -4676,7 +4669,7 @@ template <class T, class Alloc>
|
||||
<dd>
|
||||
<dl compact>
|
||||
<dt>
|
||||
<code>buffer_capacity</code>
|
||||
<code>capacity</code>
|
||||
</dt>
|
||||
<dd>
|
||||
The new capacity.
|
||||
@@ -4748,10 +4741,10 @@ template <class T, class Alloc>
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
|
||||
<code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
|
||||
"#classboost_1_1circular__buffer_1aa10b4e4ec1f1c5918931b04b31d43ca">assign(capacity_type, size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
|
||||
InputIterator)</a></code>
|
||||
|
||||
@@ -1304,9 +1304,13 @@ public:
|
||||
<dd>
|
||||
To explicitly clear the extra allocated memory use the <b>shrink-to-fit</b> technique:<br>
|
||||
<br>
|
||||
<code>boost::circular_buffer_space_optimized<int> cb(1000);<br>
|
||||
<code><a href=
|
||||
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized<int>
|
||||
cb(1000);<br>
|
||||
...<br>
|
||||
boost::circular_buffer_space_optimized<int>(cb).swap(cb);</code><br>
|
||||
<a href=
|
||||
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized<int>(cb).swap(cb);</code><br>
|
||||
|
||||
<br>
|
||||
For more information about the shrink-to-fit technique in STL see <a href=
|
||||
"http://www.gotw.ca/gotw/054.htm">http://www.gotw.ca/gotw/054.htm</a>.
|
||||
@@ -1845,9 +1849,7 @@ public:
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_177e35432c5e69b7a16ef7d937950e7a8">operator=</a></code>,
|
||||
<code><a href=
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1108055ae3f6b1635e1428b0455902cbf">assign(capacity_type,
|
||||
size_type, const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1417de2c2419c44d83a92c463762df5fb">assign(InputIterator,
|
||||
@@ -1977,9 +1979,7 @@ public:
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_177e35432c5e69b7a16ef7d937950e7a8">operator=</a></code>,
|
||||
<code><a href=
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_17ca4fda9526d0dad99706763c3b2d9f1">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1417de2c2419c44d83a92c463762df5fb">assign(InputIterator,
|
||||
@@ -2097,9 +2097,7 @@ public:
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_177e35432c5e69b7a16ef7d937950e7a8">operator=</a></code>,
|
||||
<code><a href=
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_17ca4fda9526d0dad99706763c3b2d9f1">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1108055ae3f6b1635e1428b0455902cbf">assign(capacity_type,
|
||||
@@ -2235,9 +2233,7 @@ public:
|
||||
<b>See Also:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_177e35432c5e69b7a16ef7d937950e7a8">operator=</a></code>,
|
||||
<code><a href=
|
||||
<code>operator=</code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_17ca4fda9526d0dad99706763c3b2d9f1">assign(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1108055ae3f6b1635e1428b0455902cbf">assign(capacity_type,
|
||||
|
||||
@@ -709,7 +709,7 @@ public:
|
||||
iterators pointing to the first <code>n</code> elements; does not invalidate any iterators if the
|
||||
<code>circular_buffer</code> is full.
|
||||
\par Complexity
|
||||
Linear (in <code>(std::min)(m, n)</code>); constant if the <code>circular_buffer</code> is full.
|
||||
Linear (in <code>std::min(m, n)</code>); constant if the <code>circular_buffer</code> is full.
|
||||
\sa <code><a href="http://www.sgi.com/tech/stl/rotate.html">std::rotate</a></code>
|
||||
*/
|
||||
void rotate(const_iterator new_begin) {
|
||||
@@ -998,17 +998,17 @@ public:
|
||||
|
||||
//! Create an empty <code>circular_buffer</code> with the specified capacity.
|
||||
/*!
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == 0</code>
|
||||
\param buffer_capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>.
|
||||
\post <code>capacity() == capacity \&\& size() == 0</code>
|
||||
\param capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>.
|
||||
\param alloc The allocator.
|
||||
\throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
|
||||
used).
|
||||
\par Complexity
|
||||
Constant.
|
||||
*/
|
||||
explicit circular_buffer(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type())
|
||||
explicit circular_buffer(capacity_type capacity, const allocator_type& alloc = allocator_type())
|
||||
: m_size(0), m_alloc(alloc) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
initialize_buffer(capacity);
|
||||
m_first = m_last = m_buff;
|
||||
}
|
||||
|
||||
@@ -1033,10 +1033,10 @@ public:
|
||||
|
||||
/*! \brief Create a <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
|
||||
copies of <code>item</code>.
|
||||
\pre <code>buffer_capacity >= n</code>
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\&\& ... \&\& (*this)[n - 1] == item</code>
|
||||
\param buffer_capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\pre <code>capacity >= n</code>
|
||||
\post <code>capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ...
|
||||
\&\& (*this)[n - 1] == item</code>
|
||||
\param capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\param n The number of elements the created <code>circular_buffer</code> will be filled with.
|
||||
\param item The element the created <code>circular_buffer</code> will be filled with.
|
||||
\param alloc The allocator.
|
||||
@@ -1046,13 +1046,13 @@ public:
|
||||
\par Complexity
|
||||
Linear (in the <code>n</code>).
|
||||
*/
|
||||
circular_buffer(capacity_type buffer_capacity, size_type n, param_value_type item,
|
||||
circular_buffer(capacity_type capacity, size_type n, param_value_type item,
|
||||
const allocator_type& alloc = allocator_type())
|
||||
: m_size(n), m_alloc(alloc) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= size()); // check for capacity lower than size
|
||||
initialize_buffer(buffer_capacity, item);
|
||||
BOOST_CB_ASSERT(capacity >= size()); // check for capacity lower than size
|
||||
initialize_buffer(capacity, item);
|
||||
m_first = m_buff;
|
||||
m_last = buffer_capacity == n ? m_buff : m_buff + n;
|
||||
m_last = capacity == n ? m_buff : m_buff + n;
|
||||
}
|
||||
|
||||
//! The copy constructor.
|
||||
@@ -1067,11 +1067,7 @@ public:
|
||||
Linear (in the size of <code>cb</code>).
|
||||
*/
|
||||
circular_buffer(const circular_buffer<T, Alloc>& cb)
|
||||
:
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
debug_iterator_registry(),
|
||||
#endif
|
||||
m_size(cb.size()), m_alloc(cb.get_allocator()) {
|
||||
: m_size(cb.size()), m_alloc(cb.get_allocator()) {
|
||||
initialize_buffer(cb.capacity());
|
||||
m_first = m_buff;
|
||||
BOOST_TRY {
|
||||
@@ -1130,13 +1126,13 @@ public:
|
||||
\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() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\&
|
||||
(*this)[buffer_capacity - 1] == *(last - 1)</code><br><br>
|
||||
\post <code>capacity() == capacity \&\& 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>buffer_capacity</code> then only elements from the range
|
||||
<code>[last - buffer_capacity, last)</code> will be copied.
|
||||
\param buffer_capacity The capacity of the created <code>circular_buffer</code>.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
\param capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\param first The beginning of the range to be copied.
|
||||
\param last The end of the range to be copied.
|
||||
\param alloc The allocator.
|
||||
@@ -1149,10 +1145,10 @@ public:
|
||||
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
|
||||
*/
|
||||
template <class InputIterator>
|
||||
circular_buffer(capacity_type buffer_capacity, InputIterator first, InputIterator last,
|
||||
circular_buffer(capacity_type capacity, InputIterator first, InputIterator last,
|
||||
const allocator_type& alloc = allocator_type())
|
||||
: m_alloc(alloc) {
|
||||
initialize(buffer_capacity, first, last, is_integral<InputIterator>());
|
||||
initialize(capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
@@ -1245,9 +1241,9 @@ public:
|
||||
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 <code>n</code> copies of the <code>item</code>.
|
||||
\pre <code>capacity >= n</code>
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\post <code>capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\&\& ... \&\& (*this) [n - 1] == item </code>
|
||||
\param buffer_capacity The new capacity.
|
||||
\param capacity The new capacity.
|
||||
\param n The number of elements the <code>circular_buffer</code> will be filled with.
|
||||
\param item The element the <code>circular_buffer</code> will be filled with.
|
||||
\throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
|
||||
@@ -1264,9 +1260,9 @@ public:
|
||||
assign(size_type, const_reference)\endlink</code>, <code>assign(InputIterator, InputIterator)</code>,
|
||||
<code>assign(capacity_type, InputIterator, InputIterator)</code>
|
||||
*/
|
||||
void assign(capacity_type buffer_capacity, size_type n, param_value_type item) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= n); // check for new capacity lower than n
|
||||
assign_n(buffer_capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc));
|
||||
void assign(capacity_type capacity, size_type n, param_value_type item) {
|
||||
BOOST_CB_ASSERT(capacity >= n); // check for new capacity lower than n
|
||||
assign_n(capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc));
|
||||
}
|
||||
|
||||
//! Assign a copy of the range into the <code>circular_buffer</code>.
|
||||
@@ -1309,13 +1305,13 @@ public:
|
||||
\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() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\&
|
||||
(*this)[buffer_capacity - 1] == *(last - 1)</code><br><br>
|
||||
\post <code>capacity() == capacity \&\& 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>buffer_capacity</code> then only elements from the range
|
||||
<code>[last - buffer_capacity, last)</code> will be copied.
|
||||
\param buffer_capacity The new capacity.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
\param capacity The new capacity.
|
||||
\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
|
||||
@@ -1337,8 +1333,8 @@ public:
|
||||
<code>assign(InputIterator, InputIterator)</code>
|
||||
*/
|
||||
template <class InputIterator>
|
||||
void assign(capacity_type buffer_capacity, InputIterator first, InputIterator last) {
|
||||
assign(buffer_capacity, first, last, is_integral<InputIterator>());
|
||||
void assign(capacity_type capacity, InputIterator first, InputIterator last) {
|
||||
assign(capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
//! Swap the contents of two <code>circular_buffer</code>s.
|
||||
@@ -2083,14 +2079,14 @@ private:
|
||||
}
|
||||
|
||||
//! Initialize the internal buffer.
|
||||
void initialize_buffer(capacity_type buffer_capacity) {
|
||||
m_buff = allocate(buffer_capacity);
|
||||
m_end = m_buff + buffer_capacity;
|
||||
void initialize_buffer(capacity_type capacity) {
|
||||
m_buff = allocate(capacity);
|
||||
m_end = m_buff + capacity;
|
||||
}
|
||||
|
||||
//! Initialize the internal buffer.
|
||||
void initialize_buffer(capacity_type buffer_capacity, param_value_type item) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
void initialize_buffer(capacity_type capacity, param_value_type item) {
|
||||
initialize_buffer(capacity);
|
||||
BOOST_TRY {
|
||||
cb_details::uninitialized_fill_n_with_alloc(m_buff, size(), item, m_alloc);
|
||||
} BOOST_CATCH(...) {
|
||||
@@ -2139,35 +2135,35 @@ private:
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class IntegralType>
|
||||
void initialize(capacity_type buffer_capacity, IntegralType n, IntegralType item, const true_type&) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= static_cast<size_type>(n)); // check for capacity lower than n
|
||||
void initialize(capacity_type capacity, IntegralType n, IntegralType item, const true_type&) {
|
||||
BOOST_CB_ASSERT(capacity >= static_cast<size_type>(n)); // check for capacity lower than n
|
||||
m_size = static_cast<size_type>(n);
|
||||
initialize_buffer(buffer_capacity, item);
|
||||
initialize_buffer(capacity, item);
|
||||
m_first = m_buff;
|
||||
m_last = buffer_capacity == size() ? m_buff : m_buff + size();
|
||||
m_last = capacity == size() ? m_buff : m_buff + size();
|
||||
}
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class Iterator>
|
||||
void initialize(capacity_type buffer_capacity, Iterator first, Iterator last, const false_type&) {
|
||||
void initialize(capacity_type capacity, Iterator first, Iterator last, const false_type&) {
|
||||
BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
initialize(buffer_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
initialize(capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
initialize(capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class InputIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const std::input_iterator_tag&) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
initialize_buffer(capacity);
|
||||
m_first = m_last = m_buff;
|
||||
m_size = 0;
|
||||
if (buffer_capacity == 0)
|
||||
if (capacity == 0)
|
||||
return;
|
||||
while (first != last && !full()) {
|
||||
m_alloc.construct(m_last, *first++);
|
||||
@@ -2183,32 +2179,32 @@ private:
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class ForwardIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
const std::forward_iterator_tag&) {
|
||||
BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range
|
||||
initialize(buffer_capacity, first, last, std::distance(first, last));
|
||||
initialize(capacity, first, last, std::distance(first, last));
|
||||
}
|
||||
|
||||
//! Initialize the circular buffer.
|
||||
template <class ForwardIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
size_type distance) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
initialize_buffer(capacity);
|
||||
m_first = m_buff;
|
||||
if (distance > buffer_capacity) {
|
||||
std::advance(first, distance - buffer_capacity);
|
||||
m_size = buffer_capacity;
|
||||
if (distance > capacity) {
|
||||
std::advance(first, distance - capacity);
|
||||
m_size = capacity;
|
||||
} else {
|
||||
m_size = distance;
|
||||
}
|
||||
BOOST_TRY {
|
||||
m_last = cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc);
|
||||
} BOOST_CATCH(...) {
|
||||
deallocate(m_buff, buffer_capacity);
|
||||
deallocate(m_buff, capacity);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
@@ -146,9 +146,9 @@ class capacity_control {
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
capacity_control(Size buffer_capacity, Size min_buffer_capacity = 0)
|
||||
: m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity); // check for capacity lower than min_capacity
|
||||
capacity_control(Size capacity, Size min_capacity = 0)
|
||||
: m_capacity(capacity), m_min_capacity(min_capacity) {
|
||||
BOOST_CB_ASSERT(capacity >= min_capacity); // check for capacity lower than min_capacity
|
||||
}
|
||||
|
||||
// Default copy constructor.
|
||||
|
||||
@@ -1229,8 +1229,8 @@ private:
|
||||
}
|
||||
|
||||
//! Ensure the reserve for possible growth up.
|
||||
size_type ensure_reserve(size_type new_capacity, size_type buffer_size) const {
|
||||
if (buffer_size + new_capacity / 5 >= new_capacity)
|
||||
size_type ensure_reserve(size_type new_capacity, size_type size) const {
|
||||
if (size + new_capacity / 5 >= new_capacity)
|
||||
new_capacity *= 2; // ensure at least 20% reserve
|
||||
if (new_capacity > m_capacity_ctrl)
|
||||
return m_capacity_ctrl;
|
||||
|
||||
1
module.cmake
Normal file
1
module.cmake
Normal file
@@ -0,0 +1 @@
|
||||
boost_module (circular_buffer DEPENDS config)
|
||||
7
test/CMakeLists.txt
Normal file
7
test/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
boost_additional_test_dependencies(circular_buffer BOOST_DEPENDS test )
|
||||
|
||||
|
||||
boost_test_run(base_test SINGLE_THREADED)
|
||||
boost_test_run(space_optimized_test SINGLE_THREADED)
|
||||
boost_test_run(soft_iterator_invalidation SINGLE_THREADED)
|
||||
boost_test_compile(bounded_buffer_comparison)
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <deque>
|
||||
@@ -30,11 +29,10 @@ public:
|
||||
typedef boost::circular_buffer<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -72,11 +70,10 @@ public:
|
||||
typedef boost::circular_buffer_space_optimized<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -114,11 +111,10 @@ public:
|
||||
typedef std::deque<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -157,11 +153,10 @@ public:
|
||||
typedef std::list<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
|
||||
Reference in New Issue
Block a user