Compare commits

...

15 Commits

Author SHA1 Message Date
Beman Dawes
36dee37fed Release 1.45.0
[SVN r66646]
2010-11-19 15:17:53 +00:00
Jan Gaspar
2bd298dec7 circular_buffer: applied patch to remove workaround for DEC C++ compiler - now all compilers will use this->invalidate_iterators_except
[SVN r61570]
2010-04-26 09:40:08 +00:00
Jan Gaspar
65810242ee circular_buffer: updated documentation
[SVN r60691]
2010-03-18 12:39:52 +00:00
Jan Gaspar
0282b8ee74 circular_buffer: constant complexity of clear method and destructor; added erase_begin and erase_end methods
[SVN r58681]
2010-01-04 15:54:37 +00:00
Troy D. Straszheim
cde2abac0c rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
Jan Gaspar
f2247e1b9b circular_buffer: #3285
[SVN r55260]
2009-07-29 13:20:21 +00:00
Troy D. Straszheim
d532095822 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
Jan Gaspar
5f566ba7bc circular_buffer: #2785, #3032
[SVN r53652]
2009-06-05 10:33:11 +00:00
Jeremiah Willcock
5aa54f6045 Fixed almost all tab and min/max issues found by inspect tool
[SVN r53142]
2009-05-20 19:41:20 +00:00
Douglas Gregor
8377fd145e Circular_buffer depends on Thread
[SVN r52817]
2009-05-07 04:42:14 +00:00
Troy D. Straszheim
92c290536e merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
Jan Gaspar
8a115a066a circular_buffer: #2538 Warning suppression in circular buffer test jamfile
[SVN r50107]
2008-12-04 09:09:48 +00:00
Jan Gaspar
491fd3d0ff circular_buffer: fixed MSVC9 warning
[SVN r48264]
2008-08-20 16:13:07 +00:00
Jan Gaspar
6647c9d40f circular_buffer: major update for Boost 1.37
[SVN r48190]
2008-08-18 08:54:04 +00:00
Thorsten Jørgen Ottosen
fb1828e57a default constructor changed so it does not allocate memory (it allocated a huge memory block previously).
[SVN r47559]
2008-07-18 14:18:57 +00:00
28 changed files with 1830 additions and 603 deletions

View File

@@ -1,6 +1,6 @@
# Doxygen configuration file.
#
# Copyright (c) 2003-2007 Jan Gaspar
# Copyright (c) 2003-2008 Jan Gaspar
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at

View File

@@ -2,7 +2,7 @@
# HOW-TO documentation about generating/updating source code documentation for #
# the Circular Buffer library. #
# #
# Copyright (c) 2007 Jan Gaspar #
# Copyright (c) 2003-2008 Jan Gaspar #
# #
# Use, modification, and distribution is subject to the Boost Software #
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at #

View File

@@ -1,6 +1,6 @@
# HTML Tidy configuration file.
#
# Copyright (c) 2003-2007 Jan Gaspar
# Copyright (c) 2003-2008 Jan Gaspar
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
XSL transformation from the XML files generated by Doxygen into XHTML source
code documentation of the circular_buffer.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -2,7 +2,7 @@
<!--
Helper XSL transformation making plain copy of an XML tree.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -3,7 +3,7 @@
Generic XSL transformation from the XML files generated by Doxygen into XHTML
source code documentation.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -2,7 +2,7 @@
<!--
Helper XSL transformation which converts HTML into XHTML.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -35,7 +35,8 @@
<a href="#constructors">Constructors and Destructor</a><br>
<a href="#methods">Specific Public Member Functions</a><br>
<a href="#see">See also</a><br>
<a href="#ack">Acknowledgements</a>
<a href="#ack">Acknowledgements</a><br>
<a href="#relnotes">Release Notes</a>
<h2>
<a name="description" id="description">Description</a>
</h2>
@@ -136,24 +137,24 @@ public:
"#classboost_1_1circular__buffer__space__optimized_16839c3ea656ff0f800e38096748fe8ac">~circular_buffer_space_optimized</a>();
allocator_type <a href=
"circular_buffer.html#classboost_1_1circular__buffer_15693ba52e58ef90f1d914cbb63143cd3">get_allocator</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_1a20b7d0e7a4da0af13286df9f53d660c">get_allocator</a>() const;
allocator_type&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098">get_allocator</a>();
iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin</a>();
iterator <a href="circular_buffer.html#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end</a>();
const_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1ee6c38b2ecdc8dfec79975dbc685c80b">begin</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin</a>() const;
const_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_19813e1d191cd04c4cfc100bbc4733e92">end</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end</a>() const;
reverse_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin</a>();
reverse_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend</a>();
const_reverse_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_146a8356a1aec6abca9c44cfc60b3bb10">rbegin</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin</a>() const;
const_reverse_iterator <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1a09f7111dde9f52a4d8babfcdef7e798">rend</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend</a>() const;
reference <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd">operator[]</a>(size_type index);
const_reference <a href=
@@ -167,30 +168,34 @@ public:
reference <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back</a>();
const_reference <a href=
"circular_buffer.html#classboost_1_1circular__buffer_13261c47e81bb5e447fb0d70f096728b8">front</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_10df8595d83bb9d8a7ce50aabc678f90b">front</a>() const;
const_reference <a href=
"circular_buffer.html#classboost_1_1circular__buffer_14cd3a019a9d99b4e29918b51c2181a07">back</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132">back</a>() const;
array_range <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one</a>();
array_range <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two</a>();
const_array_range <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1586cfbdef335f1d3d31faacec63f7b04">array_one</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945">array_one</a>() const;
const_array_range <a href=
"circular_buffer.html#classboost_1_1circular__buffer_191a0e2c33c0e5b4d7b8c497847bc29ce">array_two</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5">array_two</a>() const;
pointer <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize</a>();
size_type <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size</a>() const;
size_type <a href=
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size</a>() const;
bool <a href=
"circular_buffer.html#classboost_1_1circular__buffer_105acab2b9a0b41044b5241cfc9d87663">empty</a>() const;
bool <a href="#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_120f64448dc0723cc68c1096f6b00bc0a">is_linearized</a>() const;
void <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619">rotate</a>(const_iterator new_begin);
size_type <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve</a>() const;
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size</a>() const;
size_type <a href=
"circular_buffer.html#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size</a>() const;
bool <a href=
"circular_buffer.html#classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583">empty</a>() const;
bool <a href="#classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954">full</a>() const;
size_type <a href=
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve</a>() const;
const capacity_type&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity</a>() const;
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity</a>() const;
void <a href=
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity</a>(const capacity_type&amp; capacity_ctrl);
void <a href=
@@ -342,7 +347,7 @@ public:
<code>capacity &gt;= min_capacity</code>
</dd>
</dl>The <code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a></code>
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a></code>
represents the capacity of the <code>circular_buffer_space_optimized</code> and the
<code>min_capacity()</code> determines the minimal allocated size of its internal buffer. The converting
constructor of the <code>capacity_control</code> allows implicit conversion from
@@ -368,23 +373,19 @@ public:
"circular_buffer.html#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>&amp;
alloc = allocator_type());</b></code><br>
<br>
Create an empty space optimized circular buffer with a maximum capacity.
Create an empty space optimized circular buffer with zero capacity.
<dl>
<dt>
<b>Effect:</b>
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
== <a href=
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a>
&amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
== 0 &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
0</code><br>
<br>
There is no memory allocated in the internal buffer.
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
== 0 &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
0</code>
</dd>
</dl>
<dl>
@@ -418,6 +419,15 @@ public:
Constant.
</dd>
</dl>
<dl>
<dt>
<b>Warning:</b>
</dt>
<dd>
Since Boost version 1.36 the behaviour of this constructor has changed. Now it creates a space
optimized circular buffer with zero capacity.
</dd>
</dl>
</td>
</tr>
<tr>
@@ -437,9 +447,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
0</code><br>
<br>
The amount of allocated memory in the internal buffer is <code>capacity_ctrl.min_capacity()</code>.
@@ -508,9 +518,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full()</a>
"#classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954">full()</a>
&amp;&amp; (*this)[0] == item &amp;&amp; (*this)[1] == item &amp;&amp; ... &amp;&amp; (*this)
[capacity_ctrl.capacity() - 1] == item</code><br>
<br>
@@ -603,9 +613,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
&amp;&amp; (*this)[0] == item &amp;&amp; (*this)[1] == item &amp;&amp; ... &amp;&amp; (*this)[n - 1] ==
item</code><br>
<br>
@@ -765,11 +775,11 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
== std::distance(first, last) &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
== 0 &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full()</a>
"#classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954">full()</a>
&amp;&amp; (*this)[0]== *first &amp;&amp; (*this)[1] == *(first + 1) &amp;&amp; ... &amp;&amp;
(*this)[std::distance(first, last) - 1] == *(last - 1)</code><br>
<br>
@@ -862,9 +872,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
&lt;= std::distance(first, last) &amp;&amp; (*this)[0]== (last - capacity_ctrl.capacity()) &amp;&amp;
(*this)[1] == *(last - capacity_ctrl.capacity() + 1) &amp;&amp; ... &amp;&amp;
(*this)[capacity_ctrl.capacity() - 1] == *(last - 1)</code><br>
@@ -1008,8 +1018,8 @@ public:
<table id="table_methods" border="1" cellpadding="3">
<tr>
<td>
<a id="classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8" name=
"classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8"></a><code><b>bool
<a id="classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954" name=
"classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954"></a><code><b>bool
full() const;</b></code><br>
<br>
Is the <code>circular_buffer_space_optimized</code> full?
@@ -1060,15 +1070,15 @@ public:
</dt>
<dd>
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_105acab2b9a0b41044b5241cfc9d87663">empty()</a></code>
"circular_buffer.html#classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583">empty()</a></code>
</dd>
</dl>
</td>
</tr>
<tr>
<td>
<a id="classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4" name=
"classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4"></a><code><b><a href=
<a id="classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f" name=
"classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f"></a><code><b><a href=
"circular_buffer.html#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a>
reserve() const;</b></code><br>
<br>
@@ -1080,9 +1090,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
- <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
</dd>
</dl>
<dl>
@@ -1123,19 +1133,19 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a></code>,
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a></code>,
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>,
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a></code>
"circular_buffer.html#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>
</dd>
</dl>
</td>
</tr>
<tr>
<td>
<a id="classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353" name=
"classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353"></a><code><b>const
<a id="classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa" name=
"classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa"></a><code><b>const
<a href=
"#classboost_1_1circular__buffer__space__optimized_1051350e031c50c8b4a7ca1e1902e92f0">capacity_type</a>&amp;
capacity() const;</b></code><br>
@@ -1188,11 +1198,11 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a></code>,
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a></code>,
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>,
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a></code>,
"circular_buffer.html#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>,
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity(const
capacity_type&amp;)</a></code>
@@ -1216,14 +1226,14 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
&lt;= capacity_ctrl.capacity()</code><br>
<br>
If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater
than the desired new capacity then number of <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> -
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
capacity_ctrl.capacity()]</code> <b>last</b> elements will be removed and the new size will be equal to
<code>capacity_ctrl.capacity()</code>.<br>
<br>
@@ -1283,7 +1293,7 @@ public:
</dt>
<dd>
Linear (in <code>min[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>,
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>,
capacity_ctrl.capacity()]</code>).
</dd>
</dl>
@@ -1294,13 +1304,9 @@ public:
<dd>
To explicitly clear the extra allocated memory use the <b>shrink-to-fit</b> technique:<br>
<br>
<code><a href=
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized&lt;int&gt;
cb(1000);<br>
<code>boost::circular_buffer_space_optimized&lt;int&gt; cb(1000);<br>
...<br>
<a href=
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized&lt;int&gt;(cb).swap(cb);</code><br>
boost::circular_buffer_space_optimized&lt;int&gt;(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>.
@@ -1337,9 +1343,9 @@ public:
</dt>
<dd>
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
new_size &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
&gt;= new_size</code><br>
<br>
If the new size is greater than the current size, copies of <code>item</code> will be inserted at the
@@ -1349,7 +1355,7 @@ public:
<br>
If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater
than the desired new size then number of <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> -
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
new_size]</code> <b>last</b> elements will be removed. (The capacity will remain unchanged.)<br>
<br>
The amount of allocated memory in the internal buffer may be accommodated as necessary.
@@ -1449,14 +1455,14 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
&lt;= capacity_ctrl</code><br>
<br>
If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater
than the desired new capacity then number of <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> -
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
capacity_ctrl.capacity()]</code> <b>first</b> elements will be removed and the new size will be equal
to <code>capacity_ctrl.capacity()</code>.<br>
<br>
@@ -1516,7 +1522,7 @@ public:
</dt>
<dd>
Linear (in <code>min[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>,
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>,
capacity_ctrl.capacity()]</code>).
</dd>
</dl>
@@ -1551,9 +1557,9 @@ public:
</dt>
<dd>
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
new_size &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
&gt;= new_size</code><br>
<br>
If the new size is greater than the current size, copies of <code>item</code> will be inserted at the
@@ -1563,7 +1569,7 @@ public:
<br>
If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater
than the desired new size then number of <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> -
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
new_size]</code> <b>first</b> elements will be removed. (The capacity will remain unchanged.)<br>
<br>
The amount of allocated memory in the internal buffer may be accommodated as necessary.
@@ -1760,11 +1766,11 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
== n &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
== 0 &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
&amp;&amp; (*this)[0] == item &amp;&amp; (*this)[1] == item &amp;&amp; ... &amp;&amp; (*this) [n - 1]
== item</code><br>
<br>
@@ -1884,9 +1890,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
&amp;&amp; (*this)[0] == item &amp;&amp; (*this)[1] == item &amp;&amp; ... &amp;&amp; (*this) [n - 1]
== item</code><br>
<br>
@@ -2012,11 +2018,11 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
== std::distance(first, last) &amp;&amp; <a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
== 0 &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
std::distance(first, last) &amp;&amp; (*this)[0]== *first &amp;&amp; (*this)[1] == *(first + 1)
&amp;&amp; ... &amp;&amp; (*this)[std::distance(first, last) - 1] == *(last - 1)</code><br>
<br>
@@ -2135,9 +2141,9 @@ public:
</dt>
<dd>
<code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
capacity_ctrl &amp;&amp; <a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
&lt;= std::distance(first, last) &amp;&amp; (*this)[0]== *(last - capacity) &amp;&amp; (*this)[1] ==
*(last - capacity + 1) &amp;&amp; ... &amp;&amp; (*this)[capacity - 1] == *(last - 1)</code><br>
<br>
@@ -2336,7 +2342,7 @@ public:
</dt>
<dd>
if <code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
&gt; 0</code> then <code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back()</a> ==
item</code><br>
@@ -2429,7 +2435,7 @@ public:
</dt>
<dd>
if <code><a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
&gt; 0</code> then <code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f">front()</a> ==
item</code><br>
@@ -2820,12 +2826,12 @@ public:
The number of <code>min[n, (pos - <a href=
"circular_buffer.html#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>) +
<a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]</code>
elements will be inserted at the position <code>pos</code>.<br>
The number of <code>min[pos - <a href=
"circular_buffer.html#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>,
max[0, n - <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
elements will be overwritten at the beginning of the <code>circular_buffer_space_optimized</code>.<br>
(See <i>Example</i> for the explanation.)<br>
<br>
@@ -2906,9 +2912,9 @@ public:
</dt>
<dd>
Linear (in <code>min[<a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
n]</code>).
</dd>
</dl>
@@ -2986,12 +2992,12 @@ public:
Elements from the range <code>[first + max[0, distance(first, last) - (pos - <a href=
"circular_buffer.html#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>) -
<a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>],
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>],
last)</code> will be inserted at the position <code>pos</code>.<br>
The number of <code>min[pos - <a href=
"circular_buffer.html#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>,
max[0, distance(first, last) - <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
elements will be overwritten at the beginning of the <code>circular_buffer_space_optimized</code>.<br>
(See <i>Example</i> for the explanation.)<br>
<br>
@@ -3072,11 +3078,11 @@ public:
</dt>
<dd>
Linear (in <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
std::distance(first, last)]</code>; in <code>min[<a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
std::distance(first, last)]</code> if the <code>InputIterator</code> is a <a href=
"http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
</dd>
@@ -3291,12 +3297,12 @@ public:
The number of <code>min[n, (<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> -
pos) + <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]</code>
elements will be inserted before the position <code>pos</code>.<br>
The number of <code>min[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> -
pos, max[0, n - <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
elements will be overwritten at the end of the <code>circular_buffer_space_optimized</code>.<br>
(See <i>Example</i> for the explanation.)<br>
<br>
@@ -3377,9 +3383,9 @@ public:
</dt>
<dd>
Linear (in <code>min[<a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
n]</code>).
</dd>
</dl>
@@ -3457,12 +3463,12 @@ public:
Elements from the range <code>[first, last - max[0, distance(first, last) - (<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> -
pos) - <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>])</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>])</code>
will be inserted before the position <code>pos</code>.<br>
The number of <code>min[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> -
pos, max[0, distance(first, last) - <a href=
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a>]]</code>
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
elements will be overwritten at the end of the <code><a href=
"circular_buffer.html#classboost_1_1circular__buffer">circular_buffer</a></code>.<br>
(See <i>Example</i> for the explanation.)<br>
@@ -3544,11 +3550,11 @@ public:
</dt>
<dd>
Linear (in <code>[<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
std::distance(first, last)]</code>; in <code>min[<a href=
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
<a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
std::distance(first, last)]</code> if the <code>InputIterator</code> is a <a href=
"http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
</dd>
@@ -4098,7 +4104,7 @@ public:
</dt>
<dd>
<code><a href=
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
0</code><br>
<br>
The amount of allocated memory in the internal buffer may be predictively decreased.
@@ -4174,25 +4180,53 @@ public:
<p>
The idea of the space optimized circular buffer has been introduced by Pavel Vozenilek.
</p>
<h2>
<a name="relnotes" id="relnotes">Release Notes</a>
</h2>
<dl>
<dd>
<h3>
Boost 1.37
</h3>
</dd>
<dd>
<ul>
<li>Added new methods <code>is_linearized()</code> and <code>rotate(const_iterator)</code>.
</li>
</ul>
</dd>
<dd>
<h3>
Boost 1.36
</h3>
</dd>
<dd>
<ul>
<li>Changed behaviour of the <code>circular_buffer_space_optimized(const allocator_type&amp;)</code>
constructor. Since this version the constructor sets the capacity to zero.
</li>
</ul>
</dd>
<dd>
<h3>
Boost 1.35
</h3>
</dd>
<dd>
<ul>
<li>Initial release.
</li>
</ul>
</dd>
</dl>
<hr size="1">
<table id="footer" border="0" width="100%">
<tr>
<td align="left" valign="top">
<p>
<small>Copyright © 2003-2007 Jan Gaspar</small>
</p>
<p>
<small>Use, modification, and distribution is subject to the Boost Software License, Version 1.0.<br>
(See accompanying file <code>LICENSE_1_0.txt</code> or copy at <a href=
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</small>
</p>
</td>
<td align="right" valign="top">
<a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
"http://www.w3.org/Icons/valid-html401" alt="This is a Valid HTML 4.01 Transitional Document." height="31"
width="88"></a>
</td>
</tr>
</table>
<p>
<small>Copyright © 2003-2008 Jan Gaspar</small>
</p>
<p>
<small>Use, modification, and distribution is subject to the Boost Software License, Version 1.0.<br>
(See accompanying file <code>LICENSE_1_0.txt</code> or copy at <a href=
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</small>
</p>
</body>
</html>

View File

@@ -3,7 +3,7 @@
XSL transformation from the XML files generated by Doxygen into XHTML source
code documentation of the circular_buffer_space_optimized.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -68,7 +68,7 @@ http://www.boost.org/LICENSE_1_0.txt)
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="$current[string-length(normalize-space(briefdescription)) &gt; 0]">
<xsl:for-each select="$current[string-length(normalize-space(briefdescription)) &gt; 0 and normalize-space(briefdescription) != 'no-comment']">
<xsl:apply-templates select="." mode="synopsis"/>
</xsl:for-each>
</xsl:template>
@@ -96,7 +96,7 @@ http://www.boost.org/LICENSE_1_0.txt)
</xsl:template>
<xsl:template name="member-functions-details">
<xsl:for-each select="sectiondef[@kind='public-func']/memberdef[type != '' and string-length(normalize-space(briefdescription)) &gt; 0]">
<xsl:for-each select="sectiondef[@kind='public-func']/memberdef[type != '' and string-length(normalize-space(briefdescription)) &gt; 0 and normalize-space(briefdescription) != 'no-comment']">
<xsl:apply-templates select="." mode="description"/>
</xsl:for-each>
</xsl:template>

View File

@@ -3,7 +3,7 @@
# Shell script which updates the Circular Buffer library documentation with #
# the latest source code documentation (which is in the source files). #
# #
# Copyright (c) 2007 Jan Gaspar #
# Copyright (c) 2003-2008 Jan Gaspar #
# #
# Use, modification, and distribution is subject to the Boost Software #
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at #

View File

@@ -3,7 +3,7 @@
Helper XSL transformation updating source code documentation sections
in the specified HTML file.
Copyright (c) 2007 Jan Gaspar
Copyright (c) 2003-2008 Jan Gaspar
Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,6 +1,6 @@
// Circular buffer library header file.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -15,7 +15,7 @@
#pragma once
#endif
#include "circular_buffer_fwd.hpp"
#include <boost/circular_buffer_fwd.hpp>
#include <boost/detail/workaround.hpp>
// BOOST_CB_ENABLE_DEBUG: Debug support control.
@@ -60,10 +60,10 @@
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0);
#endif
#include "circular_buffer/debug.hpp"
#include "circular_buffer/details.hpp"
#include "circular_buffer/base.hpp"
#include "circular_buffer/space_optimized.hpp"
#include <boost/circular_buffer/debug.hpp>
#include <boost/circular_buffer/details.hpp>
#include <boost/circular_buffer/base.hpp>
#include <boost/circular_buffer/space_optimized.hpp>
#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
#undef BOOST_CB_IS_CONVERTIBLE

View File

@@ -1,6 +1,6 @@
// Implementation of the base circular buffer.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,6 +20,7 @@
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/is_stateless.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_scalar.hpp>
#include <algorithm>
#include <utility>
#include <deque>
@@ -393,7 +394,7 @@ public:
Does not invalidate any iterators.
\par Complexity
Constant (in the size of the <code>circular_buffer</code>).
\sa <code>operator[]</code>
\sa <code>\link operator[](size_type) operator[] \endlink</code>
*/
reference at(size_type index) {
check_position(index);
@@ -619,7 +620,7 @@ public:
\warning In general invoking any method which modifies the internal state of the <code>circular_buffer</code>
may delinearize the internal buffer and invalidate the returned pointer.
\sa <code>array_one()</code> and <code>array_two()</code> for the other option how to pass data into a legacy
C API.
C API; <code>is_linearized()</code>, <code>rotate(const_iterator)</code>
*/
pointer linearize() {
if (empty())
@@ -667,6 +668,73 @@ public:
return m_buff;
}
//! Is the <code>circular_buffer</code> linearized?
/*!
\return <code>true</code> if the internal buffer is linearized into a continuous array (i.e. the
<code>circular_buffer</code> meets a condition
<code>\&(*this)[0] \< \&(*this)[1] \< ... \< \&(*this)[size() - 1]</code>);
<code>false</code> otherwise.
\throws Nothing.
\par Exception Safety
No-throw.
\par Iterator Invalidation
Does not invalidate any iterators.
\par Complexity
Constant (in the size of the <code>circular_buffer</code>).
\sa <code>linearize()</code>, <code>array_one()</code>, <code>array_two()</code>
*/
bool is_linearized() const { return m_first < m_last || m_last == m_buff; }
//! Rotate elements in the <code>circular_buffer</code>.
/*!
A more effective implementation of
<code><a href="http://www.sgi.com/tech/stl/rotate.html">std::rotate</a></code>.
\pre <code>new_begin</code> is a valid iterator pointing to the <code>circular_buffer</code> <b>except</b> its
end.
\post Before calling the method suppose:<br><br>
<code>m == std::distance(new_begin, end())</code><br><code>n == std::distance(begin(), new_begin)</code>
<br><code>val_0 == *new_begin, val_1 == *(new_begin + 1), ... val_m == *(new_begin + m)</code><br>
<code>val_r1 == *(new_begin - 1), val_r2 == *(new_begin - 2), ... val_rn == *(new_begin - n)</code><br>
<br>then after call to the method:<br><br>
<code>val_0 == (*this)[0] \&\& val_1 == (*this)[1] \&\& ... \&\& val_m == (*this)[m - 1] \&\& val_r1 ==
(*this)[m + n - 1] \&\& val_r2 == (*this)[m + n - 2] \&\& ... \&\& val_rn == (*this)[m]</code>
\param new_begin The new beginning.
\throws Whatever <code>T::T(const T&)</code> throws.
\throws Whatever <code>T::operator = (const T&)</code> throws.
\par Exception Safety
Basic; no-throw if the <code>circular_buffer</code> is full or <code>new_begin</code> points to
<code>begin()</code> or if the operations in the <i>Throws</i> section do not throw anything.
\par Iterator Invalidation
If <code>m \< n</code> invalidates iterators pointing to the last <code>m</code> elements
(<b>including</b> <code>new_begin</code>, but not iterators equal to <code>end()</code>) else invalidates
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.
\sa <code><a href="http://www.sgi.com/tech/stl/rotate.html">std::rotate</a></code>
*/
void rotate(const_iterator new_begin) {
BOOST_CB_ASSERT(new_begin.is_valid(this)); // check for uninitialized or invalidated iterator
BOOST_CB_ASSERT(new_begin.m_it != 0); // check for iterator pointing to end()
if (full()) {
m_first = m_last = const_cast<pointer>(new_begin.m_it);
} else {
difference_type m = end() - new_begin;
difference_type n = new_begin - begin();
if (m < n) {
for (; m > 0; --m) {
push_front(back());
pop_back();
}
} else {
for (; n > 0; --n) {
push_back(front());
pop_front();
}
}
}
}
// Size and capacity
//! Get the number of elements currently stored in the <code>circular_buffer</code>.
@@ -907,36 +975,42 @@ public:
// Construction/Destruction
//! Create an empty <code>circular_buffer</code> with a maximum capacity.
//! Create an empty <code>circular_buffer</code> with zero capacity.
/*!
\post <code>capacity() == max_size() \&\& size() == 0</code>
\post <code>capacity() == 0 \&\& size() == 0</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.
\warning This constructor has been defined only due to compatibility with the STL container definition. Avoid
using it because it may allocate <b>very large</b> amount of memory (depending on allocator's
%max_size()).
\warning Since Boost version 1.36 the behaviour of this constructor has changed. Now the constructor does not
allocate any memory and both capacity and size are set to zero. Also note when inserting an element
into a <code>circular_buffer</code> with zero capacity (e.g. by
<code>\link push_back() push_back(const_reference)\endlink</code> or
<code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>) nothing
will be inserted and the size (as well as capacity) remains zero.
\note You can explicitly set the capacity by calling the <code>set_capacity(capacity_type)</code> method or you
can use the other constructor with the capacity specified.
\sa <code>circular_buffer(capacity_type, const allocator_type& alloc)</code>,
<code>set_capacity(capacity_type)</code>
*/
explicit circular_buffer(const allocator_type& alloc = allocator_type())
: m_size(0), m_alloc(alloc) {
initialize(max_size());
}
: m_buff(0), m_end(0), m_first(0), m_last(0), m_size(0), m_alloc(alloc) {}
//! Create an empty <code>circular_buffer</code> with the specified capacity.
/*!
\post <code>capacity() == capacity \&\& size() == 0</code>
\param capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>.
\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>.
\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 capacity, const allocator_type& alloc = allocator_type())
explicit circular_buffer(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type())
: m_size(0), m_alloc(alloc) {
initialize(capacity);
initialize_buffer(buffer_capacity);
m_first = m_last = m_buff;
}
/*! \brief Create a full <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
@@ -954,15 +1028,16 @@ public:
*/
circular_buffer(size_type n, param_value_type item, const allocator_type& alloc = allocator_type())
: m_size(n), m_alloc(alloc) {
initialize(n, item);
initialize_buffer(n, item);
m_first = m_last = m_buff;
}
/*! \brief Create a <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
copies of <code>item</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>.
\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>.
\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.
@@ -972,11 +1047,13 @@ public:
\par Complexity
Linear (in the <code>n</code>).
*/
circular_buffer(capacity_type capacity, size_type n, param_value_type item,
circular_buffer(capacity_type buffer_capacity, size_type n, param_value_type item,
const allocator_type& alloc = allocator_type())
: m_size(n), m_alloc(alloc) {
BOOST_CB_ASSERT(capacity >= size()); // check for capacity lower than size
initialize(capacity, item);
BOOST_CB_ASSERT(buffer_capacity >= size()); // check for capacity lower than size
initialize_buffer(buffer_capacity, item);
m_first = m_buff;
m_last = buffer_capacity == n ? m_buff : m_buff + n;
}
//! The copy constructor.
@@ -991,15 +1068,22 @@ public:
Linear (in the size of <code>cb</code>).
*/
circular_buffer(const circular_buffer<T, Alloc>& cb)
: m_size(cb.size()), m_alloc(cb.get_allocator()) {
m_first = m_last = m_buff = allocate(cb.capacity());
:
#if BOOST_CB_ENABLE_DEBUG
debug_iterator_registry(),
#endif
m_size(cb.size()), m_alloc(cb.get_allocator()) {
initialize_buffer(cb.capacity());
m_first = m_buff;
BOOST_TRY {
m_end = cb_details::uninitialized_copy_with_alloc(cb.begin(), cb.end(), m_buff, m_alloc);
m_last = cb_details::uninitialized_copy_with_alloc(cb.begin(), cb.end(), m_buff, m_alloc);
} BOOST_CATCH(...) {
deallocate(m_buff, cb.capacity());
BOOST_RETHROW
}
BOOST_CATCH_END
if (m_last == m_end)
m_last = m_buff;
}
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
@@ -1047,13 +1131,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() == capacity \&\& size() \<= std::distance(first, last) \&\&
(*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\&
(*this)[capacity - 1] == *(last - 1)</code><br><br>
\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>
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.
\param capacity The capacity of the created <code>circular_buffer</code>.
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>.
\param first The beginning of the range to be copied.
\param last The end of the range to be copied.
\param alloc The allocator.
@@ -1066,10 +1150,10 @@ public:
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
*/
template <class InputIterator>
circular_buffer(capacity_type capacity, InputIterator first, InputIterator last,
circular_buffer(capacity_type buffer_capacity, InputIterator first, InputIterator last,
const allocator_type& alloc = allocator_type())
: m_alloc(alloc) {
initialize(capacity, first, last, is_integral<InputIterator>());
initialize(buffer_capacity, first, last, is_integral<InputIterator>());
}
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
@@ -1082,7 +1166,7 @@ public:
Invalidates all iterators pointing to the <code>circular_buffer</code> (including iterators equal to
<code>end()</code>).
\par Complexity
Linear (in the size of the <code>circular_buffer</code>).
Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types.
\sa <code>clear()</code>
*/
~circular_buffer() {
@@ -1148,7 +1232,8 @@ public:
<code>end()</code>).
\par Complexity
Linear (in the <code>n</code>).
\sa <code>operator=</code>, <code>\link assign(capacity_type, size_type, param_value_type)
\sa <code>\link operator=(const circular_buffer&) operator=\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>,
<code>assign(capacity_type, InputIterator, InputIterator)</code>
@@ -1162,9 +1247,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() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
\post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
\&\& ... \&\& (*this) [n - 1] == item </code>
\param capacity The new capacity.
\param buffer_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
@@ -1177,13 +1262,14 @@ public:
<code>end()</code>).
\par Complexity
Linear (in the <code>n</code>).
\sa <code>operator=</code>, <code>\link assign(size_type, param_value_type)
assign(size_type, const_reference)\endlink</code>, <code>assign(InputIterator, InputIterator)</code>,
\sa <code>\link operator=(const circular_buffer&) operator=\endlink</code>,
<code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>,
<code>assign(InputIterator, InputIterator)</code>,
<code>assign(capacity_type, InputIterator, InputIterator)</code>
*/
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));
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));
}
//! Assign a copy of the range into the <code>circular_buffer</code>.
@@ -1208,8 +1294,8 @@ public:
<code>end()</code>).
\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>,
\sa <code>\link operator=(const circular_buffer&) operator=\endlink</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>
@@ -1226,13 +1312,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() == capacity \&\& size() \<= std::distance(first, last) \&\&
(*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\&
(*this)[capacity - 1] == *(last - 1)</code><br><br>
\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>
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.
\param capacity The new capacity.
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.
\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
@@ -1247,15 +1333,15 @@ public:
Linear (in <code>std::distance(first, last)</code>; in
<code>min[capacity, std::distance(first, last)]</code> if the <code>InputIterator</code> is a
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
\sa <code>operator=</code>, <code>\link assign(size_type, param_value_type)
assign(size_type, const_reference)\endlink</code>,
\sa <code>\link operator=(const circular_buffer&) operator=\endlink</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, InputIterator first, InputIterator last) {
assign(capacity, first, last, is_integral<InputIterator>());
void assign(capacity_type buffer_capacity, InputIterator first, InputIterator last) {
assign(buffer_capacity, first, last, is_integral<InputIterator>());
}
//! Swap the contents of two <code>circular_buffer</code>s.
@@ -1297,6 +1383,7 @@ public:
<code>0</code>, nothing will be inserted.
\param item The element to be inserted.
\throws Whatever <code>T::T(const T&)</code> throws.
\throws Whatever <code>T::operator = (const T&)</code> throws.
\par Exception Safety
Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
\par Iterator Invalidation
@@ -1327,6 +1414,7 @@ public:
<code>0</code>, nothing will be inserted.
\param item The element to be inserted.
\throws Whatever <code>T::T(const T&)</code> throws.
\throws Whatever <code>T::operator = (const T&)</code> throws.
\par Exception Safety
Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
\par Iterator Invalidation
@@ -1720,7 +1808,8 @@ public:
\par Complexity
Linear (in <code>std::distance(pos, end())</code>).
\sa <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>,
<code>rerase(iterator, iterator)</code>, <code>clear()</code>
<code>rerase(iterator, iterator)</code>, <code>erase_begin(size_type)</code>,
<code>erase_end(size_type)</code>, <code>clear()</code>
*/
iterator erase(iterator pos) {
BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator
@@ -1757,7 +1846,7 @@ public:
\par Complexity
Linear (in <code>std::distance(first, end())</code>).
\sa <code>erase(iterator)</code>, <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>,
<code>clear()</code>
<code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code>, <code>clear()</code>
*/
iterator erase(iterator first, iterator last) {
BOOST_CB_ASSERT(first.is_valid(this)); // check for uninitialized or invalidated iterator
@@ -1796,7 +1885,8 @@ public:
<code>erase(iterator)</code> if the iterator <code>pos</code> is close to the beginning of the
<code>circular_buffer</code>. (See the <i>Complexity</i>.)
\sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>,
<code>rerase(iterator, iterator)</code>, <code>clear()</code>
<code>rerase(iterator, iterator)</code>, <code>erase_begin(size_type)</code>,
<code>erase_end(size_type)</code>, <code>clear()</code>
*/
iterator rerase(iterator pos) {
BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator
@@ -1836,7 +1926,7 @@ public:
<code>erase(iterator, iterator)</code> if <code>std::distance(begin(), first)</code> is lower that
<code>std::distance(last, end())</code>.
\sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>,
<code>clear()</code>
<code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code>, <code>clear()</code>
*/
iterator rerase(iterator first, iterator last) {
BOOST_CB_ASSERT(first.is_valid(this)); // check for uninitialized or invalidated iterator
@@ -1862,6 +1952,70 @@ public:
return iterator(this, last.m_it);
}
//! Remove first <code>n</code> elements (with constant complexity for scalar types).
/*!
\pre <code>n \<= size()</code>
\post The <code>n</code> elements at the beginning of the <code>circular_buffer</code> will be removed.
\param n The number of elements to be removed.
\throws Whatever <code>T::operator = (const T&)</code> throws. (Does not throw anything in case of scalars.)
\par Exception Safety
Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw in
case of scalars.)
\par Iterator Invalidation
Invalidates iterators pointing to the first <code>n</code> erased elements.
\par Complexity
Constant (in <code>n</code>) for scalar types; linear for other types.
\note This method has been specially designed for types which do not require an explicit destructruction (e.g.
integer, float or a pointer). For these scalar types a call to a destructor is not required which makes
it possible to implement the "erase from beginning" operation with a constant complexity. For non-sacalar
types the complexity is linear (hence the explicit destruction is needed) and the implementation is
actually equivalent to
<code>\link circular_buffer::rerase(iterator, iterator) rerase(begin(), begin() + n)\endlink</code>.
\sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>,
<code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>,
<code>erase_end(size_type)</code>, <code>clear()</code>
*/
void erase_begin(size_type n) {
BOOST_CB_ASSERT(n <= size()); // check for n greater than size
#if BOOST_CB_ENABLE_DEBUG
erase_begin(n, false_type());
#else
erase_begin(n, is_scalar<value_type>());
#endif
}
//! Remove last <code>n</code> elements (with constant complexity for scalar types).
/*!
\pre <code>n \<= size()</code>
\post The <code>n</code> elements at the end of the <code>circular_buffer</code> will be removed.
\param n The number of elements to be removed.
\throws Whatever <code>T::operator = (const T&)</code> throws. (Does not throw anything in case of scalars.)
\par Exception Safety
Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw in
case of scalars.)
\par Iterator Invalidation
Invalidates iterators pointing to the last <code>n</code> erased elements.
\par Complexity
Constant (in <code>n</code>) for scalar types; linear for other types.
\note This method has been specially designed for types which do not require an explicit destructruction (e.g.
integer, float or a pointer). For these scalar types a call to a destructor is not required which makes
it possible to implement the "erase from end" operation with a constant complexity. For non-sacalar
types the complexity is linear (hence the explicit destruction is needed) and the implementation is
actually equivalent to
<code>\link circular_buffer::erase(iterator, iterator) erase(end() - n, end())\endlink</code>.
\sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>,
<code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>,
<code>erase_begin(size_type)</code>, <code>clear()</code>
*/
void erase_end(size_type n) {
BOOST_CB_ASSERT(n <= size()); // check for n greater than size
#if BOOST_CB_ENABLE_DEBUG
erase_end(n, false_type());
#else
erase_end(n, is_scalar<value_type>());
#endif
}
//! Remove all stored elements from the <code>circular_buffer</code>.
/*!
\post <code>size() == 0</code>
@@ -1872,9 +2026,10 @@ public:
Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
<code>end()</code>).
\par Complexity
Linear (in the size of the <code>circular_buffer</code>).
Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types.
\sa <code>~circular_buffer()</code>, <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>,
<code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>
<code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>,
<code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code>
*/
void clear() {
destroy_content();
@@ -1981,6 +2136,20 @@ private:
//! Destroy the whole content of the circular buffer.
void destroy_content() {
#if BOOST_CB_ENABLE_DEBUG
destroy_content(false_type());
#else
destroy_content(is_scalar<value_type>());
#endif
}
//! Specialized destroy_content method.
void destroy_content(const true_type&) {
m_first = add(m_first, size());
}
//! Specialized destroy_content method.
void destroy_content(const false_type&) {
for (size_type ii = 0; ii < size(); ++ii, increment(m_first))
destroy_item(m_first);
}
@@ -1997,15 +2166,15 @@ private:
#endif
}
//! Initialize the circular buffer.
void initialize(capacity_type capacity) {
m_first = m_last = m_buff = allocate(capacity);
m_end = m_buff + capacity;
//! Initialize the internal buffer.
void initialize_buffer(capacity_type buffer_capacity) {
m_buff = allocate(buffer_capacity);
m_end = m_buff + buffer_capacity;
}
//! Initialize the circular buffer.
void initialize(capacity_type capacity, param_value_type item) {
initialize(capacity);
//! Initialize the internal buffer.
void initialize_buffer(capacity_type buffer_capacity, param_value_type item) {
initialize_buffer(buffer_capacity);
BOOST_TRY {
cb_details::uninitialized_fill_n_with_alloc(m_buff, size(), item, m_alloc);
} BOOST_CATCH(...) {
@@ -2019,7 +2188,8 @@ private:
template <class IntegralType>
void initialize(IntegralType n, IntegralType item, const true_type&) {
m_size = static_cast<size_type>(n);
initialize(size(), item);
initialize_buffer(size(), item);
m_first = m_last = m_buff;
}
//! Specialized initialize method.
@@ -2053,32 +2223,35 @@ private:
//! Specialized initialize method.
template <class IntegralType>
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
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
m_size = static_cast<size_type>(n);
initialize(capacity, item);
initialize_buffer(buffer_capacity, item);
m_first = m_buff;
m_last = buffer_capacity == size() ? m_buff : m_buff + size();
}
//! Specialized initialize method.
template <class Iterator>
void initialize(capacity_type capacity, Iterator first, Iterator last, const false_type&) {
void initialize(capacity_type buffer_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(capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
initialize(buffer_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
#else
initialize(capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
#endif
}
//! Specialized initialize method.
template <class InputIterator>
void initialize(capacity_type capacity,
void initialize(capacity_type buffer_capacity,
InputIterator first,
InputIterator last,
const std::input_iterator_tag&) {
initialize(capacity);
initialize_buffer(buffer_capacity);
m_first = m_last = m_buff;
m_size = 0;
if (capacity == 0)
if (buffer_capacity == 0)
return;
while (first != last && !full()) {
m_alloc.construct(m_last, *first++);
@@ -2094,36 +2267,37 @@ private:
//! Specialized initialize method.
template <class ForwardIterator>
void initialize(capacity_type capacity,
void initialize(capacity_type buffer_capacity,
ForwardIterator first,
ForwardIterator last,
const std::forward_iterator_tag&) {
BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range
initialize(capacity, first, last, std::distance(first, last));
initialize(buffer_capacity, first, last, std::distance(first, last));
}
//! Helper initialize method.
//! Initialize the circular buffer.
template <class ForwardIterator>
void initialize(capacity_type capacity,
void initialize(capacity_type buffer_capacity,
ForwardIterator first,
ForwardIterator last,
size_type distance) {
initialize(capacity);
if (distance > capacity) {
std::advance(first, distance - capacity);
m_size = capacity;
initialize_buffer(buffer_capacity);
m_first = m_buff;
if (distance > buffer_capacity) {
std::advance(first, distance - buffer_capacity);
m_size = buffer_capacity;
} else {
m_size = distance;
if (distance != capacity)
m_last = m_buff + size();
}
BOOST_TRY {
cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc);
m_last = cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc);
} BOOST_CATCH(...) {
deallocate(m_buff, capacity);
deallocate(m_buff, buffer_capacity);
BOOST_RETHROW
}
BOOST_CATCH_END
if (m_last == m_end)
m_last = m_buff;
}
//! Reset the circular buffer.
@@ -2474,6 +2648,30 @@ private:
m_last = sub(m_last, n - construct);
m_size += construct;
}
//! Specialized erase_begin method.
void erase_begin(size_type n, const true_type&) {
m_first = add(m_first, n);
m_size -= n;
}
//! Specialized erase_begin method.
void erase_begin(size_type n, const false_type&) {
iterator b = begin();
rerase(b, b + n);
}
//! Specialized erase_end method.
void erase_end(size_type n, const true_type&) {
m_last = sub(m_last, n);
m_size -= n;
}
//! Specialized erase_end method.
void erase_end(size_type n, const false_type&) {
iterator e = end();
erase(e - n, e);
}
};
// Non-member functions

View File

@@ -1,6 +1,6 @@
// Debug support for the circular buffer library.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Helper classes and functions for the circular buffer.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -66,16 +66,6 @@ struct nonconst_traits {
typedef nonconst_traits<Traits> nonconst_self;
};
/*!
\struct helper_pointer
\brief Helper pointer used in the iterator.
*/
template <class Traits>
struct helper_pointer {
bool m_end;
typename Traits::pointer m_it;
};
/*!
\struct iterator_wrapper
\brief Helper iterator dereference wrapper.
@@ -141,7 +131,7 @@ private:
};
/*!
\struct capacity_control
\class capacity_control
\brief Capacity controller of the space optimized circular buffer.
*/
template <class Size>
@@ -156,9 +146,9 @@ class capacity_control {
public:
//! Constructor.
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
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
}
// Default copy constructor.
@@ -176,7 +166,7 @@ public:
};
/*!
\class iterator
\struct iterator
\brief Random access iterator for the circular buffer.
\param Buff The type of the underlying circular buffer.
\param Traits Basic iterator types.
@@ -184,7 +174,7 @@ public:
for iterating from begin() to end() of the circular buffer.
*/
template <class Buff, class Traits>
class iterator :
struct iterator :
public boost::iterator<
std::random_access_iterator_tag,
typename Traits::value_type,
@@ -195,7 +185,6 @@ class iterator :
, public debug_iterator_base
#endif // #if BOOST_CB_ENABLE_DEBUG
{
private:
// Helper types
//! Base iterator.
@@ -209,7 +198,6 @@ private:
//! Non-const iterator.
typedef iterator<Buff, typename Traits::nonconst_self> nonconst_self;
public:
// Basic types
//! The type of the elements stored in the circular buffer.
@@ -227,7 +215,6 @@ public:
//! Difference type.
typedef typename base_iterator::difference_type difference_type;
public:
// Member variables
//! The circular buffer where the iterator points to.
@@ -236,7 +223,6 @@ public:
//! An internal iterator.
pointer m_it;
public:
// Construction & assignment
// Default copy constructor.
@@ -288,16 +274,11 @@ public:
pointer operator -> () const { return &(operator*()); }
//! Difference operator.
difference_type operator - (const iterator& it) const {
template <class Traits0>
difference_type operator - (const iterator<Buff, Traits0>& it) const {
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
helper_pointer<Traits> lhs = create_helper_pointer(*this);
helper_pointer<Traits> rhs = create_helper_pointer(it);
if (less(rhs, lhs) && lhs.m_it <= rhs.m_it)
return (lhs.m_it - rhs.m_it) + static_cast<difference_type>(m_buff->capacity());
if (less(lhs, rhs) && lhs.m_it >= rhs.m_it)
return (lhs.m_it - rhs.m_it) - static_cast<difference_type>(m_buff->capacity());
return lhs.m_it - rhs.m_it;
return linearize_pointer(*this) - linearize_pointer(it);
}
//! Increment operator (prefix).
@@ -355,7 +336,7 @@ public:
iterator& operator -= (difference_type n) {
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
if (n > 0) {
BOOST_CB_ASSERT(m_buff->begin() - *this <= -n); // check for too large n
BOOST_CB_ASSERT(*this - m_buff->begin() >= n); // check for too large n
m_it = m_buff->sub(m_it == 0 ? m_buff->m_last : m_it, n);
} else if (n < 0) {
*this += -n;
@@ -392,12 +373,12 @@ public:
bool operator < (const iterator<Buff, Traits0>& it) const {
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
return less(create_helper_pointer(*this), create_helper_pointer(it));
return linearize_pointer(*this) < linearize_pointer(it);
}
//! Greater.
template <class Traits0>
bool operator > (const iterator<Buff, Traits0>& it) const { return it < *this; }
bool operator > (const iterator<Buff, Traits0>& it) const { return it < *this; }
//! Less or equal.
template <class Traits0>
@@ -407,44 +388,14 @@ public:
template <class Traits0>
bool operator >= (const iterator<Buff, Traits0>& it) const { return !(*this < it); }
private:
// Helpers
//! Create helper pointer.
//! Get a pointer which would point to the same element as the iterator in case the circular buffer is linearized.
template <class Traits0>
helper_pointer<Traits0> create_helper_pointer(const iterator<Buff, Traits0>& it) const {
helper_pointer<Traits0> helper;
helper.m_end = (it.m_it == 0);
helper.m_it = helper.m_end ? m_buff->m_last : it.m_it;
return helper;
}
//! Less.
template <class InternalIterator0, class InternalIterator1>
bool less(const InternalIterator0& lhs, const InternalIterator1& rhs) const {
difference_type ldiff = lhs.m_it - m_buff->m_first;
difference_type rdiff = rhs.m_it - m_buff->m_first;
if (ldiff < 0) {
if (rdiff < 0)
return lhs.m_it < rhs.m_it;
else if (rdiff == 0)
return rhs.m_end;
} else if (ldiff == 0) {
if (rdiff < 0)
return !lhs.m_end;
else if (rdiff == 0)
return !lhs.m_end && rhs.m_end;
else
return !lhs.m_end;
} else { // ldiff > 0
if (rdiff < 0)
return true;
else if (rdiff == 0)
return rhs.m_end;
else
return lhs.m_it < rhs.m_it;
}
return false;
typename Traits0::pointer linearize_pointer(const iterator<Buff, Traits0>& it) const {
return it.m_it == 0 ? m_buff->m_buff + m_buff->size() :
(it.m_it < m_buff->m_first ? it.m_it + (m_buff->m_end - m_buff->m_first)
: m_buff->m_buff + (it.m_it - m_buff->m_first));
}
};

View File

@@ -1,6 +1,6 @@
// Implementation of the circular buffer adaptor.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -90,6 +90,8 @@ public:
using circular_buffer<T, Alloc>::array_one;
using circular_buffer<T, Alloc>::array_two;
using circular_buffer<T, Alloc>::linearize;
using circular_buffer<T, Alloc>::is_linearized;
using circular_buffer<T, Alloc>::rotate;
using circular_buffer<T, Alloc>::size;
using circular_buffer<T, Alloc>::max_size;
using circular_buffer<T, Alloc>::empty;
@@ -187,9 +189,9 @@ public:
\par Complexity
Linear (in <code>min[size(), capacity_ctrl.%capacity()]</code>).
\note 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>%boost::%circular_buffer_space_optimized\<int\> cb(1000);<br>
...<br>
boost::%circular_buffer_space_optimized\<int\>(cb).swap(cb);</code><br><br>
%boost::%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>.
\sa <code>rset_capacity(const capacity_type&)</code>,
@@ -312,18 +314,19 @@ public:
}
}
//! Create an empty space optimized circular buffer with a maximum capacity.
//! Create an empty space optimized circular buffer with zero capacity.
/*!
\post <code>capacity().%capacity() == max_size() \&\& capacity().min_capacity() == 0 \&\& size() == 0</code>
<br><br>There is no memory allocated in the internal buffer.
\post <code>capacity().%capacity() == 0 \&\& capacity().min_capacity() == 0 \&\& size() == 0</code>
\param alloc The allocator.
\throws Nothing.
\par Complexity
Constant.
\warning Since Boost version 1.36 the behaviour of this constructor has changed. Now it creates a space
optimized circular buffer with zero capacity.
*/
explicit circular_buffer_space_optimized(const allocator_type& alloc = allocator_type())
: circular_buffer<T, Alloc>(0, alloc)
, m_capacity_ctrl(max_size()) {}
, m_capacity_ctrl(0) {}
//! Create an empty space optimized circular buffer with the specified capacity.
/*!
@@ -510,6 +513,12 @@ public:
*/
~circular_buffer_space_optimized();
//! no-comment
void erase_begin(size_type n);
//! no-comment
void erase_end(size_type n);
#endif // #if defined(BOOST_CB_NEVER_DEFINED)
//! The assign operator.
@@ -562,7 +571,8 @@ public:
equal to <code>end()</code>).
\par Complexity
Linear (in the <code>n</code>).
\sa <code>operator=</code>, <code>\link assign(capacity_type, size_type, param_value_type)
\sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\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>,
<code>assign(capacity_type, InputIterator, InputIterator)</code>
@@ -594,8 +604,9 @@ public:
equal to <code>end()</code>).
\par Complexity
Linear (in the <code>n</code>).
\sa <code>operator=</code>, <code>\link assign(size_type, param_value_type)
assign(size_type, const_reference)\endlink</code>, <code>assign(InputIterator, InputIterator)</code>,
\sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</code>,
<code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>,
<code>assign(InputIterator, InputIterator)</code>,
<code>assign(capacity_type, InputIterator, InputIterator)</code>
*/
void assign(capacity_type capacity_ctrl, size_type n, param_value_type item) {
@@ -627,8 +638,8 @@ public:
equal to <code>end()</code>).
\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>,
\sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</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>
@@ -669,8 +680,8 @@ public:
Linear (in <code>std::distance(first, last)</code>; in
<code>min[capacity_ctrl.%capacity(), std::distance(first, last)]</code> if the <code>InputIterator</code>
is a <a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
\sa <code>operator=</code>, <code>\link assign(size_type, param_value_type)
assign(size_type, const_reference)\endlink</code>,
\sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</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>
@@ -1226,8 +1237,8 @@ private:
}
//! Ensure the reserve for possible growth up.
size_type ensure_reserve(size_type new_capacity, size_type size) const {
if (size + new_capacity / 5 >= new_capacity)
size_type ensure_reserve(size_type new_capacity, size_type buffer_size) const {
if (buffer_size + new_capacity / 5 >= new_capacity)
new_capacity *= 2; // ensure at least 20% reserve
if (new_capacity > m_capacity_ctrl)
return m_capacity_ctrl;
@@ -1249,11 +1260,7 @@ private:
ensure_reserve(new_capacity, new_size));
}
#if BOOST_CB_ENABLE_DEBUG
# if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(70190006))
this->invalidate_iterators_except(end());
# else
invalidate_iterators_except(end());
# endif
#endif
}
@@ -1273,11 +1280,7 @@ private:
circular_buffer<T, Alloc>::set_capacity(
ensure_reserve(new_capacity, size()));
#if BOOST_CB_ENABLE_DEBUG
# if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(70190006))
this->invalidate_iterators_except(end());
# else
invalidate_iterators_except(end());
# endif
#endif
}

View File

@@ -1,6 +1,6 @@
// Forward declaration of the circular buffer and its adaptor.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -11,7 +11,7 @@
<body>
Automatic redirection failed, please go to <a href="doc/circular_buffer.html">circular_buffer.html</a>.
<p>
<small>Copyright © 2003-2007 Jan Gaspar</small>
<small>Copyright © 2003-2008 Jan Gaspar</small>
</p>
<p>
<small>Use, modification, and distribution is subject to the Boost Software License, Version 1.0.<br>

View File

@@ -1,17 +1,30 @@
# Boost circular_buffer test Jamfile.
#
# Copyright (c) 2003-2007 Jan Gaspar
# Copyright (c) 2003-2008 Jan Gaspar
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Added warning supression Paul A. Bristow 25 Nov 2008
# Bring in rules for testing.
import testing ;
project
: requirements
<toolset>msvc:<warnings>all
<toolset>msvc:<asynch-exceptions>on
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<cxxflags>/wd4996 # 'function': was declared deprecated
<toolset>msvc:<cxxflags>/wd4244 # conversion from 'int' to 'unsigned short', possible loss of data
# in date-time
;
test-suite "circular_buffer"
: [ run base_test.cpp : <threading>single : ]
[ run space_optimized_test.cpp : <threading>single : ]
[ run soft_iterator_invalidation.cpp : <threading>single : ]
[ run constant_erase_test.cpp : <threading>single : ]
[ compile bounded_buffer_comparison.cpp : <threading>multi : ]
;

View File

@@ -1,6 +1,6 @@
// Test of the base circular buffer container.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -61,6 +61,7 @@ void iterator_difference_test() {
BOOST_CHECK(end - end == 0);
BOOST_CHECK(begin - cb.end() == -5);
BOOST_CHECK(it1 - cb.begin() == 2);
BOOST_CHECK(it1 - begin == 2);
BOOST_CHECK(end - it1 == 3);
BOOST_CHECK(it2 - it1 == 1);
BOOST_CHECK(it1 - it2 == -1);
@@ -189,7 +190,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)
@@ -506,6 +506,62 @@ void iterator_invalidation_test() {
BOOST_CHECK(!it3.is_valid(&cb13));
BOOST_CHECK(!it4.is_valid(&cb13));
circular_buffer<MyInteger> cb14(10);
cb14.push_back(1);
cb14.push_back(2);
cb14.push_back(3);
cb14.push_back(4);
cb14.push_back(5);
cb14.push_back(6);
cb14.push_back(7);
it1 = cb14.end();
it2 = cb14.begin() + 2;
it3 = cb14.begin() + 1;
it4 = cb14.begin() + 5;
cb14.rotate(it2);
BOOST_CHECK(it1.is_valid(&cb14));
BOOST_CHECK(it2.is_valid(&cb14));
BOOST_CHECK(!it3.is_valid(&cb14));
BOOST_CHECK(it4.is_valid(&cb14));
circular_buffer<MyInteger> cb15(7);
cb15.push_back(1);
cb15.push_back(2);
cb15.push_back(3);
cb15.push_back(4);
cb15.push_back(5);
cb15.push_back(6);
cb15.push_back(7);
cb15.push_back(8);
cb15.push_back(9);
it1 = cb15.end();
it2 = cb15.begin() + 2;
it3 = cb15.begin() + 1;
it4 = cb15.begin() + 5;
cb15.rotate(it3);
BOOST_CHECK(it1.is_valid(&cb15));
BOOST_CHECK(it2.is_valid(&cb15));
BOOST_CHECK(it3.is_valid(&cb15));
BOOST_CHECK(it4.is_valid(&cb15));
circular_buffer<MyInteger> cb16(10);
cb16.push_back(1);
cb16.push_back(2);
cb16.push_back(3);
cb16.push_back(4);
cb16.push_back(5);
cb16.push_back(6);
cb16.push_back(7);
it1 = cb16.end();
it2 = cb16.begin() + 6;
it3 = cb16.begin();
it4 = cb16.begin() + 5;
cb16.rotate(it4);
BOOST_CHECK(it1.is_valid(&cb16));
BOOST_CHECK(!it2.is_valid(&cb16));
BOOST_CHECK(it3.is_valid(&cb16));
BOOST_CHECK(!it4.is_valid(&cb16));
#endif // #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG)
}

View File

@@ -1,6 +1,6 @@
// Comparison of bounded buffers based on different containers.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -12,6 +12,7 @@
#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>
@@ -29,10 +30,11 @@ 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(const value_type& item) {
void push_front(param_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);
@@ -70,10 +72,11 @@ 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(const value_type& item) {
void push_front(param_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);
@@ -111,10 +114,11 @@ 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(const value_type& item) {
void push_front(param_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);
@@ -153,10 +157,11 @@ 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(const value_type& item) {
void push_front(param_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);

View File

@@ -1,6 +1,6 @@
// Common tests for the circular buffer and its adaptor.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -328,8 +328,16 @@ void linearize_test() {
cb6.push_back(5);
cb6.push_back(6);
cb6.pop_back();
CB_CONTAINER<MyInteger> cb7(6);
cb7.push_back(0);
cb7.push_back(1);
cb7.push_back(2);
cb7.push_back(3);
cb7.push_back(4);
BOOST_CHECK(!cb1.is_linearized());
BOOST_CHECK(*cb1.linearize() == 4);
BOOST_CHECK(cb1.is_linearized());
BOOST_CHECK(cb1.linearize() == cb1.array_one().first);
BOOST_CHECK(&cb1[0] < &cb1[1]
&& &cb1[1] < &cb1[2]
@@ -349,7 +357,9 @@ void linearize_test() {
BOOST_CHECK(*(cb1.linearize() + 7) == 11);
BOOST_CHECK(*(cb1.linearize() + 8) == 12);
BOOST_CHECK(*(cb1.linearize() + 9) == 13);
BOOST_CHECK(!cb2.is_linearized());
BOOST_CHECK(*cb2.linearize() == 8);
BOOST_CHECK(cb2.is_linearized());
BOOST_CHECK(&cb2[0] < &cb2[1]
&& &cb2[1] < &cb2[2]
&& &cb2[2] < &cb2[3]
@@ -368,7 +378,9 @@ void linearize_test() {
BOOST_CHECK(*(cb2.linearize() + 7) == 15);
BOOST_CHECK(*(cb2.linearize() + 8) == 16);
BOOST_CHECK(*(cb2.linearize() + 9) == 17);
BOOST_CHECK(cb2.is_linearized());
BOOST_CHECK(*cb3.linearize() == 6);
BOOST_CHECK(cb3.is_linearized());
BOOST_CHECK(&cb3[0] < &cb3[1]
&& &cb3[1] < &cb3[2]
&& &cb3[2] < &cb3[3]
@@ -384,7 +396,9 @@ void linearize_test() {
BOOST_CHECK(*(cb3.linearize() + 6) == 12);
BOOST_CHECK(*(cb3.linearize() + 7) == 13);
BOOST_CHECK(cb4.linearize() == 0);
BOOST_CHECK(cb4.is_linearized());
BOOST_CHECK(*cb5.linearize() == 10);
BOOST_CHECK(cb5.is_linearized());
BOOST_CHECK(&cb5[0] < &cb5[1]
&& &cb5[1] < &cb5[2]
&& &cb5[2] < &cb5[3]
@@ -396,6 +410,7 @@ void linearize_test() {
BOOST_CHECK(*(cb5.linearize() + 4) == 14);
BOOST_CHECK(*(cb5.linearize() + 5) == 15);
BOOST_CHECK(*cb6.linearize() == 1);
BOOST_CHECK(cb6.is_linearized());
BOOST_CHECK(&cb6[0] < &cb6[1]
&& &cb6[1] < &cb6[2]
&& &cb6[2] < &cb6[3]
@@ -404,6 +419,7 @@ void linearize_test() {
BOOST_CHECK(*(cb6.linearize() + 2) == 3);
BOOST_CHECK(*(cb6.linearize() + 3) == 4);
BOOST_CHECK(*(cb6.linearize() + 4) == 5);
BOOST_CHECK(cb7.is_linearized());
generic_test(cb1);
generic_test(cb2);
@@ -411,6 +427,7 @@ void linearize_test() {
generic_test(cb4);
generic_test(cb5);
generic_test(cb6);
generic_test(cb7);
}
void array_range_test() {
@@ -769,6 +786,17 @@ void rresize_test() {
void constructor_test() {
CB_CONTAINER<MyInteger> cb0;
BOOST_CHECK(cb0.capacity() == 0);
BOOST_CHECK(cb0.size() == 0);
cb0.push_back(1);
cb0.push_back(2);
cb0.push_back(3);
BOOST_CHECK(cb0.size() == 0);
BOOST_CHECK(cb0.capacity() == 0);
CB_CONTAINER<MyInteger> cb1(3);
CB_CONTAINER<MyInteger> cb2(3, 2);
vector<int> v;
@@ -780,6 +808,7 @@ void constructor_test() {
CB_CONTAINER<MyInteger> cb3(v.begin(), v.end());
CB_CONTAINER<MyInteger> cb4(3, v.begin(), v.end());
CB_CONTAINER<MyInteger> cb5(10, v.begin(), v.end());
CB_CONTAINER<MyInteger> cb6(10, 3, MyInteger(2));
BOOST_CHECK(cb1.size() == 0);
BOOST_CHECK(cb1.capacity() == 3);
@@ -803,19 +832,29 @@ void constructor_test() {
BOOST_CHECK(!cb5.full());
BOOST_CHECK(cb5[0] == 1);
BOOST_CHECK(cb5[4] == 5);
BOOST_CHECK(cb6.size() == 3);
BOOST_CHECK(cb6.capacity() == 10);
BOOST_CHECK(!cb6.full());
BOOST_CHECK(cb6[0] == 2);
BOOST_CHECK(cb6[2] == 2);
cb5.push_back(6);
cb6.push_back(6);
BOOST_CHECK(cb5[5] == 6);
BOOST_CHECK(cb5[0] == 1);
BOOST_CHECK(cb5.size() == 6);
BOOST_CHECK(cb6[3] == 6);
BOOST_CHECK(cb6.size() == 4);
BOOST_CHECK(cb6[0] == 2);
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
CB_CONTAINER<int> cb6(MyInputIterator(v.begin()), MyInputIterator(v.end()));
CB_CONTAINER<int> cb7(3, MyInputIterator(v.begin()), MyInputIterator(v.end()));
CB_CONTAINER<int> cb7(MyInputIterator(v.begin()), MyInputIterator(v.end()));
CB_CONTAINER<int> cb8(3, MyInputIterator(v.begin()), MyInputIterator(v.end()));
BOOST_CHECK(cb6.capacity() == 5);
BOOST_CHECK(cb7.capacity() == 3);
BOOST_CHECK(cb7.capacity() == 5);
BOOST_CHECK(cb8.capacity() == 3);
#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
@@ -824,6 +863,7 @@ void constructor_test() {
generic_test(cb3);
generic_test(cb4);
generic_test(cb5);
generic_test(cb6);
}
void assign_test() {
@@ -894,6 +934,9 @@ void copy_constructor_and_assign_test() {
CB_CONTAINER<MyInteger> cb2 = cb1;
BOOST_CHECK(cb1 == cb2);
BOOST_CHECK(cb2.capacity() == 4);
BOOST_CHECK(cb2[0] == 2);
BOOST_CHECK(cb2[3] == 5);
CB_CONTAINER<MyInteger> cb3(20);
cb1.pop_back();
@@ -901,6 +944,7 @@ void copy_constructor_and_assign_test() {
cb3 = cb2;
cb3 = cb3;
cb4 = cb1;
CB_CONTAINER<MyInteger> cb5 = cb1;
BOOST_CHECK(cb3 == cb2);
BOOST_CHECK(cb4 == cb1);
@@ -911,11 +955,16 @@ void copy_constructor_and_assign_test() {
BOOST_CHECK(cb4.capacity() == 4);
BOOST_CHECK(!cb4.full());
BOOST_CHECK(*(cb4.end() - 1) == 4);
BOOST_CHECK(cb1 == cb5);
BOOST_CHECK(cb5.capacity() == 4);
BOOST_CHECK(cb2[0] == 2);
BOOST_CHECK(cb2[2] == 4);
generic_test(cb1);
generic_test(cb2);
generic_test(cb3);
generic_test(cb4);
generic_test(cb5);
}
void swap_test() {
@@ -1781,6 +1830,122 @@ void const_methods_test() {
BOOST_CHECK(cb.back() == 5);
}
void rotate_test() {
CB_CONTAINER<MyInteger> cb1(10);
cb1.push_back(1);
cb1.push_back(2);
cb1.push_back(3);
cb1.push_back(4);
cb1.push_back(5);
cb1.push_back(6);
cb1.push_back(7);
CB_CONTAINER<MyInteger> cb2 = cb1;
CB_CONTAINER<MyInteger>::iterator it1 = cb1.begin() + 2;
int v1_0 = *it1;
int v1_1 = *(it1 + 1);
int v1_2 = *(it1 + 2);
int v1_3 = *(it1 + 3);
int v1_4 = *(it1 + 4);
int v1_r1 = *(it1 - 1);
int v1_r2 = *(it1 - 2);
cb1.rotate(it1);
rotate(cb2.begin(), cb2.begin() + 2, cb2.end());
CB_CONTAINER<MyInteger> cb3(7);
cb3.push_back(1);
cb3.push_back(2);
cb3.push_back(3);
cb3.push_back(4);
cb3.push_back(5);
cb3.push_back(6);
cb3.push_back(7);
cb3.push_back(8);
cb3.push_back(9);
CB_CONTAINER<MyInteger> cb4 = cb3;
CB_CONTAINER<MyInteger>::iterator it2 = cb3.begin() + 1;
int v2_0 = *it2;
int v2_1 = *(it2 + 1);
int v2_2 = *(it2 + 2);
int v2_3 = *(it2 + 3);
int v2_4 = *(it2 + 4);
int v2_5 = *(it2 + 5);
int v2_r1 = *(it2 - 1);
cb3.rotate(it2);
rotate(cb4.begin(), cb4.begin() + 1, cb4.end());
CB_CONTAINER<MyInteger> cb5(10);
cb5.push_back(1);
cb5.push_back(2);
cb5.push_back(3);
cb5.push_back(4);
cb5.push_back(5);
cb5.push_back(6);
cb5.push_back(7);
CB_CONTAINER<MyInteger> cb6 = cb5;
CB_CONTAINER<MyInteger>::iterator it3 = cb5.begin() + 5;
int v3_0 = *it3;
int v3_1 = *(it3 + 1);
int v3_r1 = *(it3 - 1);
int v3_r2 = *(it3 - 2);
int v3_r3 = *(it3 - 3);
int v3_r4 = *(it3 - 4);
int v3_r5 = *(it3 - 5);
cb5.rotate(it3);
rotate(cb6.begin(), cb6.begin() + 5, cb6.end());
BOOST_CHECK(!cb1.full());
BOOST_CHECK(cb1 == cb2);
BOOST_CHECK(v1_0 == *it1);
BOOST_CHECK(v1_1 == *(it1 + 1));
BOOST_CHECK(v1_2 == *(it1 + 2));
BOOST_CHECK(v1_3 == *(it1 + 3));
BOOST_CHECK(v1_4 == *(it1 + 4));
BOOST_CHECK(v1_r1 == *(it1 + 6));
BOOST_CHECK(v1_r2 == *(it1 + 5));
BOOST_CHECK(cb1.begin() == it1);
BOOST_CHECK(v1_0 == cb1[0]);
BOOST_CHECK(v1_1 == cb1[1]);
BOOST_CHECK(v1_2 == cb1[2]);
BOOST_CHECK(v1_3 == cb1[3]);
BOOST_CHECK(v1_4 == cb1[4]);
BOOST_CHECK(v1_r1 == cb1[6]);
BOOST_CHECK(v1_r2 == cb1[5]);
BOOST_CHECK(cb3.full());
BOOST_CHECK(cb3 == cb4);
BOOST_CHECK(v2_0 == *it2);
BOOST_CHECK(v2_1 == *(it2 + 1));
BOOST_CHECK(v2_2 == *(it2 + 2));
BOOST_CHECK(v2_3 == *(it2 + 3));
BOOST_CHECK(v2_4 == *(it2 + 4));
BOOST_CHECK(v2_5 == *(it2 + 5));
BOOST_CHECK(v2_r1 == *(it2 + 6));
BOOST_CHECK(cb3.begin() == it2);
BOOST_CHECK(v2_0 == cb3[0]);
BOOST_CHECK(v2_1 == cb3[1]);
BOOST_CHECK(v2_2 == cb3[2]);
BOOST_CHECK(v2_3 == cb3[3]);
BOOST_CHECK(v2_4 == cb3[4]);
BOOST_CHECK(v2_5 == cb3[5]);
BOOST_CHECK(v2_r1 == cb3[6]);
BOOST_CHECK(!cb5.full());
BOOST_CHECK(cb5 == cb6);
BOOST_CHECK(v3_0 == cb5[0]);
BOOST_CHECK(v3_1 == cb5[1]);
BOOST_CHECK(v3_r1 == cb5[6]);
BOOST_CHECK(v3_r2 == cb5[5]);
BOOST_CHECK(v3_r3 == cb5[4]);
BOOST_CHECK(v3_r4 == cb5[3]);
BOOST_CHECK(v3_r5 == cb5[2]);
generic_test(cb1);
generic_test(cb2);
generic_test(cb3);
generic_test(cb4);
generic_test(cb5);
generic_test(cb6);
}
int MyInteger::ms_exception_trigger = 0;
int InstanceCounter::ms_count = 0;
@@ -1828,4 +1993,5 @@ void add_common_tests(test_suite* tests) {
tests->add(BOOST_TEST_CASE(&example_test));
tests->add(BOOST_TEST_CASE(&element_destruction_test));
tests->add(BOOST_TEST_CASE(&const_methods_test));
tests->add(BOOST_TEST_CASE(&rotate_test));
}

View File

@@ -0,0 +1,187 @@
// Special tests for erase_begin, erase_end and clear methods.
// Copyright (c) 2009 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_CB_DISABLE_DEBUG
#include "test.hpp"
int MyInteger::ms_exception_trigger = 0;
int InstanceCounter::ms_count = 0;
void erase_begin_test() {
circular_buffer<int> cb1(5);
cb1.push_back(1);
cb1.push_back(2);
cb1.push_back(3);
cb1.push_back(4);
cb1.push_back(5);
cb1.push_back(6);
circular_buffer<int>::pointer p = &cb1[0];
cb1.erase_begin(2);
BOOST_CHECK(cb1.size() == 3);
BOOST_CHECK(cb1[0] == 4);
BOOST_CHECK(cb1[1] == 5);
BOOST_CHECK(cb1[2] == 6);
cb1.erase_begin(3);
BOOST_CHECK(cb1.empty());
BOOST_CHECK(*p == 2);
BOOST_CHECK(*(p + 1) == 3);
BOOST_CHECK(*(p + 2) == 4);
cb1.push_back(10);
cb1.push_back(11);
cb1.push_back(12);
BOOST_CHECK(cb1.size() == 3);
BOOST_CHECK(cb1[0] == 10);
BOOST_CHECK(cb1[1] == 11);
BOOST_CHECK(cb1[2] == 12);
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
BOOST_CHECK(cb2.size() == 5);
BOOST_CHECK(InstanceCounter::count() == 5);
cb2.erase_begin(2);
BOOST_CHECK(cb2.size() == 3);
BOOST_CHECK(InstanceCounter::count() == 3);
circular_buffer<MyInteger> cb3(5);
cb3.push_back(1);
cb3.push_back(2);
cb3.push_back(3);
cb3.push_back(4);
cb3.push_back(5);
cb3.push_back(6);
cb3.erase_begin(2);
BOOST_CHECK(cb3.size() == 3);
BOOST_CHECK(cb3[0] == 4);
BOOST_CHECK(cb3[1] == 5);
BOOST_CHECK(cb3[2] == 6);
}
void erase_end_test() {
circular_buffer<int> cb1(5);
cb1.push_back(1);
cb1.push_back(2);
cb1.push_back(3);
cb1.push_back(4);
cb1.push_back(5);
cb1.push_back(6);
circular_buffer<int>::pointer p = &cb1[3];
cb1.erase_end(2);
BOOST_CHECK(cb1.size() == 3);
BOOST_CHECK(cb1[0] == 2);
BOOST_CHECK(cb1[1] == 3);
BOOST_CHECK(cb1[2] ==4);
cb1.erase_end(3);
BOOST_CHECK(cb1.empty());
BOOST_CHECK(*p == 5);
BOOST_CHECK(*(p - 1) == 4);
BOOST_CHECK(*(p - 2) == 3);
cb1.push_back(10);
cb1.push_back(11);
cb1.push_back(12);
BOOST_CHECK(cb1.size() == 3);
BOOST_CHECK(cb1[0] == 10);
BOOST_CHECK(cb1[1] == 11);
BOOST_CHECK(cb1[2] == 12);
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
BOOST_CHECK(cb2.size() == 5);
BOOST_CHECK(InstanceCounter::count() == 5);
cb2.erase_end(2);
BOOST_CHECK(cb2.size() == 3);
BOOST_CHECK(InstanceCounter::count() == 3);
circular_buffer<MyInteger> cb3(5);
cb3.push_back(1);
cb3.push_back(2);
cb3.push_back(3);
cb3.push_back(4);
cb3.push_back(5);
cb3.push_back(6);
cb3.erase_end(2);
BOOST_CHECK(cb3.size() == 3);
BOOST_CHECK(cb3[0] == 2);
BOOST_CHECK(cb3[1] == 3);
BOOST_CHECK(cb3[2] == 4);
}
void clear_test() {
circular_buffer<int> cb1(5);
cb1.push_back(1);
cb1.push_back(2);
cb1.push_back(3);
cb1.push_back(4);
cb1.push_back(5);
cb1.push_back(6);
circular_buffer<int>::pointer p = &cb1[0];
cb1.clear();
BOOST_CHECK(cb1.empty());
BOOST_CHECK(*p == 2);
BOOST_CHECK(*(p + 1) == 3);
BOOST_CHECK(*(p + 2) == 4);
BOOST_CHECK(*(p + 3) == 5);
BOOST_CHECK(*(p - 1) == 6);
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
BOOST_CHECK(cb2.size() == 5);
BOOST_CHECK(InstanceCounter::count() == 5);
cb2.clear();
BOOST_CHECK(cb2.empty());
BOOST_CHECK(InstanceCounter::count() == 0);
circular_buffer<MyInteger> cb3(5);
cb3.push_back(1);
cb3.push_back(2);
cb3.push_back(3);
cb3.push_back(4);
cb3.push_back(5);
cb3.push_back(6);
cb3.clear();
BOOST_CHECK(cb3.empty());
}
// test main
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
test_suite* tests = BOOST_TEST_SUITE("Unit tests for erase_begin/end and clear methods of the circular_buffer.");
tests->add(BOOST_TEST_CASE(&erase_begin_test));
tests->add(BOOST_TEST_CASE(&erase_end_test));
tests->add(BOOST_TEST_CASE(&clear_test));
return tests;
}

View File

@@ -3,7 +3,7 @@
// Note: The soft iterator invalidation definition CAN NOT be applied
// to the space optimized circular buffer.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Test of the space optimized adaptor of the circular buffer.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -62,7 +62,7 @@ void capacity_control_test() {
circular_buffer_space_optimized<int>::capacity_type c1 = 10;
circular_buffer_space_optimized<int>::capacity_type c2 =
circular_buffer_space_optimized<int>::capacity_type(20, 5);
circular_buffer_space_optimized<int>::capacity_type(20, 5);
circular_buffer_space_optimized<int>::capacity_type c3 = c2;
BOOST_CHECK(c1.capacity() == 10);
@@ -78,10 +78,10 @@ void capacity_control_test() {
BOOST_CHECK(c1.min_capacity() == 5);
}
void some_constructors_test() {
void specific_constructors_test() {
cb_space_optimized cb1;
BOOST_CHECK(cb1.capacity() == cb1.max_size());
BOOST_CHECK(cb1.capacity() == 0);
BOOST_CHECK(cb1.capacity().min_capacity() == 0);
BOOST_CHECK(cb1.internal_capacity() == 0);
BOOST_CHECK(cb1.size() == 0);
@@ -90,10 +90,15 @@ void some_constructors_test() {
cb1.push_back(2);
cb1.push_back(3);
BOOST_CHECK(cb1.size() == 3);
BOOST_CHECK(cb1.capacity() == cb1.max_size());
BOOST_CHECK(cb1.size() == 0);
BOOST_CHECK(cb1.capacity() == 0);
cb_space_optimized cb2(cb1.begin(), cb1.end());
vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
cb_space_optimized cb2(v.begin(), v.end());
BOOST_CHECK(cb2.capacity() == 3);
BOOST_CHECK(cb2.capacity().min_capacity() == 0);
@@ -183,7 +188,7 @@ test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
tests->add(BOOST_TEST_CASE(&min_capacity_test));
tests->add(BOOST_TEST_CASE(&capacity_control_test));
tests->add(BOOST_TEST_CASE(&some_constructors_test));
tests->add(BOOST_TEST_CASE(&specific_constructors_test));
tests->add(BOOST_TEST_CASE(&shrink_to_fit_test));
tests->add(BOOST_TEST_CASE(&iterator_invalidation_test));

View File

@@ -1,6 +1,6 @@
// Header file for the test of the circular buffer library.
// Copyright (c) 2003-2007 Jan Gaspar
// Copyright (c) 2003-2008 Jan Gaspar
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at