mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 09:02:12 +00:00
Compare commits
1 Commits
boost-1.41
...
boost-1.35
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ed9f6133 |
@@ -1,6 +1,6 @@
|
||||
# Doxygen configuration file.
|
||||
#
|
||||
# Copyright (c) 2003-2008 Jan Gaspar
|
||||
# Copyright (c) 2003-2007 Jan Gaspar
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See
|
||||
# accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# HOW-TO documentation about generating/updating source code documentation for #
|
||||
# the Circular Buffer library. #
|
||||
# #
|
||||
# Copyright (c) 2003-2008 Jan Gaspar #
|
||||
# Copyright (c) 2007 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 #
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# HTML Tidy configuration file.
|
||||
#
|
||||
# Copyright (c) 2003-2008 Jan Gaspar
|
||||
# Copyright (c) 2003-2007 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
@@ -3,7 +3,7 @@
|
||||
XSL transformation from the XML files generated by Doxygen into XHTML source
|
||||
code documentation of the circular_buffer.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
Helper XSL transformation making plain copy of an XML tree.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Generic XSL transformation from the XML files generated by Doxygen into XHTML
|
||||
source code documentation.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
Helper XSL transformation which converts HTML into XHTML.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
<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><br>
|
||||
<a href="#relnotes">Release Notes</a>
|
||||
<a href="#ack">Acknowledgements</a>
|
||||
<h2>
|
||||
<a name="description" id="description">Description</a>
|
||||
</h2>
|
||||
@@ -137,24 +136,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_1a20b7d0e7a4da0af13286df9f53d660c">get_allocator</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15693ba52e58ef90f1d914cbb63143cd3">get_allocator</a>() const;
|
||||
allocator_type& <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_10640d3d41c13b6089b6f169224cf1038">begin</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1ee6c38b2ecdc8dfec79975dbc685c80b">begin</a>() const;
|
||||
const_iterator <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_19813e1d191cd04c4cfc100bbc4733e92">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_1765d91bf48341907418433a1e3aab026">rbegin</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_146a8356a1aec6abca9c44cfc60b3bb10">rbegin</a>() const;
|
||||
const_reverse_iterator <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1a09f7111dde9f52a4d8babfcdef7e798">rend</a>() const;
|
||||
reference <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd">operator[]</a>(size_type index);
|
||||
const_reference <a href=
|
||||
@@ -168,34 +167,30 @@ 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_10df8595d83bb9d8a7ce50aabc678f90b">front</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_13261c47e81bb5e447fb0d70f096728b8">front</a>() const;
|
||||
const_reference <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132">back</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_14cd3a019a9d99b4e29918b51c2181a07">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_10f4b157e27b1170a571417986b239945">array_one</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1586cfbdef335f1d3d31faacec63f7b04">array_one</a>() const;
|
||||
const_array_range <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5">array_two</a>() const;
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_191a0e2c33c0e5b4d7b8c497847bc29ce">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_120f64448dc0723cc68c1096f6b00bc0a">is_linearized</a>() const;
|
||||
void <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619">rotate</a>(const_iterator new_begin);
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_105acab2b9a0b41044b5241cfc9d87663">empty</a>() const;
|
||||
bool <a href="#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full</a>() const;
|
||||
size_type <a href=
|
||||
"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;
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve</a>() const;
|
||||
const capacity_type& <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity</a>() const;
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity</a>() const;
|
||||
void <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity</a>(const capacity_type& capacity_ctrl);
|
||||
void <a href=
|
||||
@@ -347,7 +342,7 @@ public:
|
||||
<code>capacity >= min_capacity</code>
|
||||
</dd>
|
||||
</dl>The <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">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
|
||||
@@ -373,19 +368,23 @@ public:
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>&
|
||||
alloc = allocator_type());</b></code><br>
|
||||
<br>
|
||||
Create an empty space optimized circular buffer with zero capacity.
|
||||
Create an empty space optimized circular buffer with a maximum capacity.
|
||||
<dl>
|
||||
<dt>
|
||||
<b>Effect:</b>
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
== <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a>
|
||||
&& <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
|
||||
== 0 && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
|
||||
== 0 && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
0</code>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
0</code><br>
|
||||
<br>
|
||||
There is no memory allocated in the internal buffer.
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -419,15 +418,6 @@ 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>
|
||||
@@ -447,9 +437,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
0</code><br>
|
||||
<br>
|
||||
The amount of allocated memory in the internal buffer is <code>capacity_ctrl.min_capacity()</code>.
|
||||
@@ -518,9 +508,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954">full()</a>
|
||||
"#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full()</a>
|
||||
&& (*this)[0] == item && (*this)[1] == item && ... && (*this)
|
||||
[capacity_ctrl.capacity() - 1] == item</code><br>
|
||||
<br>
|
||||
@@ -613,9 +603,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
|
||||
&& (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] ==
|
||||
item</code><br>
|
||||
<br>
|
||||
@@ -775,11 +765,11 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
== std::distance(first, last) && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
|
||||
== 0 && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954">full()</a>
|
||||
"#classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8">full()</a>
|
||||
&& (*this)[0]== *first && (*this)[1] == *(first + 1) && ... &&
|
||||
(*this)[std::distance(first, last) - 1] == *(last - 1)</code><br>
|
||||
<br>
|
||||
@@ -872,9 +862,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
|
||||
<= std::distance(first, last) && (*this)[0]== (last - capacity_ctrl.capacity()) &&
|
||||
(*this)[1] == *(last - capacity_ctrl.capacity() + 1) && ... &&
|
||||
(*this)[capacity_ctrl.capacity() - 1] == *(last - 1)</code><br>
|
||||
@@ -1018,8 +1008,8 @@ public:
|
||||
<table id="table_methods" border="1" cellpadding="3">
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_142f4a13c50904a4ac0bf746c88451954"></a><code><b>bool
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_15f5e6fb070d2484eaa037cdf4ffd69a8"></a><code><b>bool
|
||||
full() const;</b></code><br>
|
||||
<br>
|
||||
Is the <code>circular_buffer_space_optimized</code> full?
|
||||
@@ -1070,15 +1060,15 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583">empty()</a></code>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_105acab2b9a0b41044b5241cfc9d87663">empty()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f"></a><code><b><a href=
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4"></a><code><b><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a>
|
||||
reserve() const;</b></code><br>
|
||||
<br>
|
||||
@@ -1090,9 +1080,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
- <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@@ -1133,19 +1123,19 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a></code>,
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>,
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa"></a><code><b>const
|
||||
<a id="classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353" name=
|
||||
"classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353"></a><code><b>const
|
||||
<a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1051350e031c50c8b4a7ca1e1902e92f0">capacity_type</a>&
|
||||
capacity() const;</b></code><br>
|
||||
@@ -1198,14 +1188,13 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">reserve()</a></code>,
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a></code>,
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>,
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_195158ed4d4b03794068e259f85291995">max_size()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity(const
|
||||
capacity_type&)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -1226,14 +1215,14 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
|
||||
<= 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_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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>
|
||||
@@ -1293,7 +1282,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>min[<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>,
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>,
|
||||
capacity_ctrl.capacity()]</code>).
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1304,9 +1293,13 @@ public:
|
||||
<dd>
|
||||
To explicitly clear the extra allocated memory use the <b>shrink-to-fit</b> technique:<br>
|
||||
<br>
|
||||
<code>boost::circular_buffer_space_optimized<int> cb(1000);<br>
|
||||
<code><a href=
|
||||
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized<int>
|
||||
cb(1000);<br>
|
||||
...<br>
|
||||
boost::circular_buffer_space_optimized<int>(cb).swap(cb);</code><br>
|
||||
<a href=
|
||||
"circular_buffer.html#namespaceboost">boost</a>::circular_buffer_space_optimized<int>(cb).swap(cb);</code><br>
|
||||
|
||||
<br>
|
||||
For more information about the shrink-to-fit technique in STL see <a href=
|
||||
"http://www.gotw.ca/gotw/054.htm">http://www.gotw.ca/gotw/054.htm</a>.
|
||||
@@ -1318,10 +1311,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_10f096c108ebde69ae83a9de41b3bea56">rset_capacity(const
|
||||
capacity_type&)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f244ff5576b79f8d60e273c02d71c9f2">resize(size_type,
|
||||
const_reference)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_10f096c108ebde69ae83a9de41b3bea56">rset_capacity()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f244ff5576b79f8d60e273c02d71c9f2">resize()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -1343,9 +1335,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
new_size && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
>= 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
|
||||
@@ -1355,7 +1347,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_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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.
|
||||
@@ -1431,10 +1423,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d45e2e72d9e3fb42e090ebc47ac8d7ee">rresize(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity(const
|
||||
capacity_type&)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d45e2e72d9e3fb42e090ebc47ac8d7ee">rresize()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -1455,14 +1446,14 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
|
||||
<= 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_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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>
|
||||
@@ -1522,7 +1513,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>min[<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>,
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>,
|
||||
capacity_ctrl.capacity()]</code>).
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1532,10 +1523,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity(const
|
||||
capacity_type&)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d45e2e72d9e3fb42e090ebc47ac8d7ee">rresize(size_type,
|
||||
const_reference)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d45e2e72d9e3fb42e090ebc47ac8d7ee">rresize()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -1557,9 +1547,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
new_size && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
>= 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
|
||||
@@ -1569,7 +1559,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_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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.
|
||||
@@ -1645,10 +1635,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f244ff5576b79f8d60e273c02d71c9f2">resize(size_type,
|
||||
const_reference)</a></code>, <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_10f096c108ebde69ae83a9de41b3bea56">rset_capacity(const
|
||||
capacity_type&)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d45e2e72d9e3fb42e090ebc47ac8d7ee">rresize()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_149f28bc5b33d2062b9f6a33b48264e3f">set_capacity()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -1766,11 +1755,11 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
== n && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
|
||||
== 0 && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
|
||||
&& (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1]
|
||||
== item</code><br>
|
||||
<br>
|
||||
@@ -1890,9 +1879,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> == n
|
||||
&& (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1]
|
||||
== item</code><br>
|
||||
<br>
|
||||
@@ -2018,11 +2007,11 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
== std::distance(first, last) && <a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.min_capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.min_capacity()
|
||||
== 0 && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
std::distance(first, last) && (*this)[0]== *first && (*this)[1] == *(first + 1)
|
||||
&& ... && (*this)[std::distance(first, last) - 1] == *(last - 1)</code><br>
|
||||
<br>
|
||||
@@ -2141,9 +2130,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a> ==
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a> ==
|
||||
capacity_ctrl && <a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a>
|
||||
<= std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] ==
|
||||
*(last - capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)</code><br>
|
||||
<br>
|
||||
@@ -2342,7 +2331,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
if <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
> 0</code> then <code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back()</a> ==
|
||||
item</code><br>
|
||||
@@ -2411,7 +2400,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front(const_reference)</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_19c4290c18ab3dd2462dc01fb8368dff6">pop_back()</a></code>,
|
||||
<code><a href=
|
||||
@@ -2435,7 +2424,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
if <code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity()
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity()
|
||||
> 0</code> then <code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f">front()</a> ==
|
||||
item</code><br>
|
||||
@@ -2504,7 +2493,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back(const_reference)</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_19c4290c18ab3dd2462dc01fb8368dff6">pop_back()</a></code>,
|
||||
<code><a href=
|
||||
@@ -2581,9 +2570,9 @@ public:
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1d7d496c40fc053258ac7d19cf5261788">pop_front()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back(const_reference)</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front(const_reference)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -2656,9 +2645,9 @@ public:
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_19c4290c18ab3dd2462dc01fb8368dff6">pop_back()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back(const_reference)</a></code>,
|
||||
"#classboost_1_1circular__buffer__space__optimized_1cf3ffed54f5fece9315fb96726e5e205">push_back()</a></code>,
|
||||
<code><a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front(const_reference)</a></code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_1f0484fd492b377ff80c0bcb76183162c">push_front()</a></code>
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
@@ -2826,12 +2815,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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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>
|
||||
@@ -2912,9 +2901,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>min[<a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
|
||||
<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
|
||||
n]</code>).
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -2992,12 +2981,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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>],
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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>
|
||||
@@ -3078,11 +3067,11 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>[<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
|
||||
std::distance(first, last)]</code>; in <code>min[<a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
|
||||
<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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>
|
||||
@@ -3297,12 +3286,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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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>
|
||||
@@ -3383,9 +3372,9 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>min[<a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
|
||||
<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
|
||||
n]</code>).
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -3463,12 +3452,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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>])</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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_170eec72a6e8d088b58e26ac7e2dd7c9f">reserve()</a>]]</code>
|
||||
"#classboost_1_1circular__buffer__space__optimized_100d0c06a38f789ae760709cc86420ae4">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>
|
||||
@@ -3550,11 +3539,11 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
Linear (in <code>[<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> +
|
||||
std::distance(first, last)]</code>; in <code>min[<a href=
|
||||
"#classboost_1_1circular__buffer__space__optimized_1aa2695c84ac9fc912e28d1a5920dadfa">capacity()</a>.capacity(),
|
||||
"#classboost_1_1circular__buffer__space__optimized_1ea8a89fbae5e03b364ac28e5dc49e353">capacity()</a>.capacity(),
|
||||
<a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> +
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">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>
|
||||
@@ -4104,7 +4093,7 @@ public:
|
||||
</dt>
|
||||
<dd>
|
||||
<code><a href=
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
|
||||
"circular_buffer.html#classboost_1_1circular__buffer_1d666f694897465b0d4d7cdd8ddcbc213">size()</a> ==
|
||||
0</code><br>
|
||||
<br>
|
||||
The amount of allocated memory in the internal buffer may be predictively decreased.
|
||||
@@ -4180,53 +4169,25 @@ 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&)</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">
|
||||
<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>
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
@@ -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) 2003-2008 Jan Gaspar #
|
||||
# Copyright (c) 2007 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 #
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Helper XSL transformation updating source code documentation sections
|
||||
in the specified HTML file.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
Copyright (c) 2007 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
|
||||
|
||||
BIN
doc/valid-html40.png
Normal file
BIN
doc/valid-html40.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -1,6 +1,6 @@
|
||||
// Circular buffer library header file.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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 <boost/circular_buffer_fwd.hpp>
|
||||
#include "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 <boost/circular_buffer/debug.hpp>
|
||||
#include <boost/circular_buffer/details.hpp>
|
||||
#include <boost/circular_buffer/base.hpp>
|
||||
#include <boost/circular_buffer/space_optimized.hpp>
|
||||
#include "circular_buffer/debug.hpp"
|
||||
#include "circular_buffer/details.hpp"
|
||||
#include "circular_buffer/base.hpp"
|
||||
#include "circular_buffer/space_optimized.hpp"
|
||||
|
||||
#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
#undef BOOST_CB_IS_CONVERTIBLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Implementation of the base circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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
|
||||
@@ -619,7 +619,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; <code>is_linearized()</code>, <code>rotate(const_iterator)</code>
|
||||
C API.
|
||||
*/
|
||||
pointer linearize() {
|
||||
if (empty())
|
||||
@@ -667,73 +667,6 @@ 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>.
|
||||
@@ -746,13 +679,12 @@ public:
|
||||
Does not invalidate any iterators.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>capacity()</code>, <code>max_size()</code>, <code>reserve()</code>,
|
||||
<code>\link resize() resize(size_type, const_reference)\endlink</code>
|
||||
\sa <code>capacity()</code>, <code>max_size()</code>, <code>reserve()</code>, <code>resize()</code>
|
||||
*/
|
||||
size_type size() const { return m_size; }
|
||||
|
||||
/*! \brief Get the largest possible size or capacity of the <code>circular_buffer</code>. (It depends on
|
||||
allocator's %max_size()).
|
||||
//! Get the largest possible size or capacity of the <code>circular_buffer</code>.
|
||||
/*!
|
||||
\return The maximum size/capacity the <code>circular_buffer</code> can be set to.
|
||||
\throws Nothing.
|
||||
\par Exception Safety
|
||||
@@ -821,8 +753,7 @@ public:
|
||||
Does not invalidate any iterators.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>,
|
||||
<code>set_capacity(capacity_type)</code>
|
||||
\sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
capacity_type capacity() const { return m_end - m_buff; }
|
||||
|
||||
@@ -843,8 +774,7 @@ public:
|
||||
<code>end()</code>) if the new capacity is different from the original.
|
||||
\par Complexity
|
||||
Linear (in <code>min[size(), new_capacity]</code>).
|
||||
\sa <code>rset_capacity(capacity_type)</code>,
|
||||
<code>\link resize() resize(size_type, const_reference)\endlink</code>
|
||||
\sa <code>rset_capacity()</code>, <code>resize()</code>
|
||||
*/
|
||||
void set_capacity(capacity_type new_capacity) {
|
||||
if (new_capacity == capacity())
|
||||
@@ -886,8 +816,7 @@ public:
|
||||
any iterator.
|
||||
\par Complexity
|
||||
Linear (in the new size of the <code>circular_buffer</code>).
|
||||
\sa <code>\link rresize() rresize(size_type, const_reference)\endlink</code>,
|
||||
<code>set_capacity(capacity_type)</code>
|
||||
\sa <code>rresize()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
void resize(size_type new_size, param_value_type item = value_type()) {
|
||||
if (new_size > size()) {
|
||||
@@ -917,8 +846,7 @@ public:
|
||||
<code>end()</code>) if the new capacity is different from the original.
|
||||
\par Complexity
|
||||
Linear (in <code>min[size(), new_capacity]</code>).
|
||||
\sa <code>set_capacity(capacity_type)</code>,
|
||||
<code>\link rresize() rresize(size_type, const_reference)\endlink</code>
|
||||
\sa <code>set_capacity()</code>, <code>rresize()</code>
|
||||
*/
|
||||
void rset_capacity(capacity_type new_capacity) {
|
||||
if (new_capacity == capacity())
|
||||
@@ -959,8 +887,7 @@ public:
|
||||
any iterator.
|
||||
\par Complexity
|
||||
Linear (in the new size of the <code>circular_buffer</code>).
|
||||
\sa <code>\link resize() resize(size_type, const_reference)\endlink</code>,
|
||||
<code>rset_capacity(capacity_type)</code>
|
||||
\sa <code>rresize()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
void rresize(size_type new_size, param_value_type item = value_type()) {
|
||||
if (new_size > size()) {
|
||||
@@ -974,42 +901,35 @@ public:
|
||||
|
||||
// Construction/Destruction
|
||||
|
||||
//! Create an empty <code>circular_buffer</code> with zero capacity.
|
||||
//! Create an empty <code>circular_buffer</code> with a maximum capacity.
|
||||
/*!
|
||||
\post <code>capacity() == 0 \&\& size() == 0</code>
|
||||
\post <code>capacity() == max_size() \&\& 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 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>
|
||||
\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.
|
||||
*/
|
||||
explicit circular_buffer(const allocator_type& alloc = allocator_type())
|
||||
: m_buff(0), m_end(0), m_first(0), m_last(0), m_size(0), m_alloc(alloc) {}
|
||||
: m_size(0), m_alloc(alloc) {
|
||||
initialize(max_size());
|
||||
}
|
||||
|
||||
//! Create an empty <code>circular_buffer</code> with the specified capacity.
|
||||
/*!
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == 0</code>
|
||||
\param buffer_capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>.
|
||||
\post <code>capacity() == capacity \&\& size() == 0</code>
|
||||
\param capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>.
|
||||
\param alloc The allocator.
|
||||
\throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
|
||||
used).
|
||||
\par Complexity
|
||||
Constant.
|
||||
*/
|
||||
explicit circular_buffer(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type())
|
||||
explicit circular_buffer(capacity_type capacity, const allocator_type& alloc = allocator_type())
|
||||
: m_size(0), m_alloc(alloc) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
m_first = m_last = m_buff;
|
||||
initialize(capacity);
|
||||
}
|
||||
|
||||
/*! \brief Create a full <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
|
||||
@@ -1027,16 +947,15 @@ public:
|
||||
*/
|
||||
circular_buffer(size_type n, param_value_type item, const allocator_type& alloc = allocator_type())
|
||||
: m_size(n), m_alloc(alloc) {
|
||||
initialize_buffer(n, item);
|
||||
m_first = m_last = m_buff;
|
||||
initialize(n, item);
|
||||
}
|
||||
|
||||
/*! \brief Create a <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
|
||||
copies of <code>item</code>.
|
||||
\pre <code>buffer_capacity >= n</code>
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\&\& ... \&\& (*this)[n - 1] == item</code>
|
||||
\param buffer_capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\pre <code>capacity >= n</code>
|
||||
\post <code>capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ...
|
||||
\&\& (*this)[n - 1] == item</code>
|
||||
\param capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\param n The number of elements the created <code>circular_buffer</code> will be filled with.
|
||||
\param item The element the created <code>circular_buffer</code> will be filled with.
|
||||
\param alloc The allocator.
|
||||
@@ -1046,13 +965,11 @@ public:
|
||||
\par Complexity
|
||||
Linear (in the <code>n</code>).
|
||||
*/
|
||||
circular_buffer(capacity_type buffer_capacity, size_type n, param_value_type item,
|
||||
circular_buffer(capacity_type capacity, size_type n, param_value_type item,
|
||||
const allocator_type& alloc = allocator_type())
|
||||
: m_size(n), m_alloc(alloc) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= size()); // check for capacity lower than size
|
||||
initialize_buffer(buffer_capacity, item);
|
||||
m_first = m_buff;
|
||||
m_last = buffer_capacity == n ? m_buff : m_buff + n;
|
||||
BOOST_CB_ASSERT(capacity >= size()); // check for capacity lower than size
|
||||
initialize(capacity, item);
|
||||
}
|
||||
|
||||
//! The copy constructor.
|
||||
@@ -1067,22 +984,15 @@ public:
|
||||
Linear (in the size of <code>cb</code>).
|
||||
*/
|
||||
circular_buffer(const circular_buffer<T, Alloc>& cb)
|
||||
:
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
debug_iterator_registry(),
|
||||
#endif
|
||||
m_size(cb.size()), m_alloc(cb.get_allocator()) {
|
||||
initialize_buffer(cb.capacity());
|
||||
m_first = m_buff;
|
||||
: m_size(cb.size()), m_alloc(cb.get_allocator()) {
|
||||
m_first = m_last = m_buff = allocate(cb.capacity());
|
||||
BOOST_TRY {
|
||||
m_last = cb_details::uninitialized_copy_with_alloc(cb.begin(), cb.end(), m_buff, m_alloc);
|
||||
m_end = 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)
|
||||
@@ -1130,13 +1040,13 @@ public:
|
||||
\pre Valid range <code>[first, last)</code>.<br>
|
||||
<code>first</code> and <code>last</code> have to meet the requirements of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
\post <code>capacity() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\&
|
||||
(*this)[buffer_capacity - 1] == *(last - 1)</code><br><br>
|
||||
\post <code>capacity() == capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\&
|
||||
(*this)[capacity - 1] == *(last - 1)</code><br><br>
|
||||
If the number of items to be copied from the range <code>[first, last)</code> is greater than the
|
||||
specified <code>buffer_capacity</code> then only elements from the range
|
||||
<code>[last - buffer_capacity, last)</code> will be copied.
|
||||
\param buffer_capacity The capacity of the created <code>circular_buffer</code>.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
\param capacity The capacity of the created <code>circular_buffer</code>.
|
||||
\param first The beginning of the range to be copied.
|
||||
\param last The end of the range to be copied.
|
||||
\param alloc The allocator.
|
||||
@@ -1149,10 +1059,10 @@ public:
|
||||
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
|
||||
*/
|
||||
template <class InputIterator>
|
||||
circular_buffer(capacity_type buffer_capacity, InputIterator first, InputIterator last,
|
||||
circular_buffer(capacity_type capacity, InputIterator first, InputIterator last,
|
||||
const allocator_type& alloc = allocator_type())
|
||||
: m_alloc(alloc) {
|
||||
initialize(buffer_capacity, first, last, is_integral<InputIterator>());
|
||||
initialize(capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
@@ -1245,9 +1155,9 @@ public:
|
||||
The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of the
|
||||
<code>circular_buffer</code> will be removed and replaced with <code>n</code> copies of the <code>item</code>.
|
||||
\pre <code>capacity >= n</code>
|
||||
\post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\post <code>capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item
|
||||
\&\& ... \&\& (*this) [n - 1] == item </code>
|
||||
\param buffer_capacity The new capacity.
|
||||
\param capacity The new capacity.
|
||||
\param n The number of elements the <code>circular_buffer</code> will be filled with.
|
||||
\param item The element the <code>circular_buffer</code> will be filled with.
|
||||
\throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
|
||||
@@ -1264,9 +1174,9 @@ public:
|
||||
assign(size_type, const_reference)\endlink</code>, <code>assign(InputIterator, InputIterator)</code>,
|
||||
<code>assign(capacity_type, InputIterator, InputIterator)</code>
|
||||
*/
|
||||
void assign(capacity_type buffer_capacity, size_type n, param_value_type item) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= n); // check for new capacity lower than n
|
||||
assign_n(buffer_capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc));
|
||||
void assign(capacity_type capacity, size_type n, param_value_type item) {
|
||||
BOOST_CB_ASSERT(capacity >= n); // check for new capacity lower than n
|
||||
assign_n(capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc));
|
||||
}
|
||||
|
||||
//! Assign a copy of the range into the <code>circular_buffer</code>.
|
||||
@@ -1309,13 +1219,13 @@ public:
|
||||
\pre Valid range <code>[first, last)</code>.<br>
|
||||
<code>first</code> and <code>last</code> have to meet the requirements of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
\post <code>capacity() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\&
|
||||
(*this)[buffer_capacity - 1] == *(last - 1)</code><br><br>
|
||||
\post <code>capacity() == capacity \&\& size() \<= std::distance(first, last) \&\&
|
||||
(*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\&
|
||||
(*this)[capacity - 1] == *(last - 1)</code><br><br>
|
||||
If the number of items to be copied from the range <code>[first, last)</code> is greater than the
|
||||
specified <code>buffer_capacity</code> then only elements from the range
|
||||
<code>[last - buffer_capacity, last)</code> will be copied.
|
||||
\param buffer_capacity The new capacity.
|
||||
specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code>
|
||||
will be copied.
|
||||
\param capacity The new capacity.
|
||||
\param first The beginning of the range to be copied.
|
||||
\param last The end of the range to be copied.
|
||||
\throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
|
||||
@@ -1337,8 +1247,8 @@ public:
|
||||
<code>assign(InputIterator, InputIterator)</code>
|
||||
*/
|
||||
template <class InputIterator>
|
||||
void assign(capacity_type buffer_capacity, InputIterator first, InputIterator last) {
|
||||
assign(buffer_capacity, first, last, is_integral<InputIterator>());
|
||||
void assign(capacity_type capacity, InputIterator first, InputIterator last) {
|
||||
assign(capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
//! Swap the contents of two <code>circular_buffer</code>s.
|
||||
@@ -1380,15 +1290,13 @@ 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
|
||||
Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>\link push_front() push_front(const_reference)\endlink</code>,
|
||||
<code>pop_back()</code>, <code>pop_front()</code>
|
||||
\sa <code>push_front()</code>, <code>pop_back()</code>, <code>pop_front()</code>
|
||||
*/
|
||||
void push_back(param_value_type item = value_type()) {
|
||||
if (full()) {
|
||||
@@ -1411,15 +1319,13 @@ 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
|
||||
Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>\link push_back() push_back(const_reference)\endlink</code>,
|
||||
<code>pop_back()</code>, <code>pop_front()</code>
|
||||
\sa <code>push_back()</code>, <code>pop_back()</code>, <code>pop_front()</code>
|
||||
*/
|
||||
void push_front(param_value_type item = value_type()) {
|
||||
BOOST_TRY {
|
||||
@@ -1452,8 +1358,7 @@ public:
|
||||
Invalidates only iterators pointing to the removed element.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>pop_front()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>,
|
||||
<code>\link push_front() push_front(const_reference)\endlink</code>
|
||||
\sa <code>pop_front()</code>, <code>push_back()</code>, <code>push_front()</code>
|
||||
*/
|
||||
void pop_back() {
|
||||
BOOST_CB_ASSERT(!empty()); // check for empty buffer (back element not available)
|
||||
@@ -1473,8 +1378,7 @@ public:
|
||||
Invalidates only iterators pointing to the removed element.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer</code>).
|
||||
\sa <code>pop_back()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>,
|
||||
<code>\link push_front() push_front(const_reference)\endlink</code>
|
||||
\sa <code>pop_back()</code>, <code>push_back()</code>, <code>push_front()</code>
|
||||
*/
|
||||
void pop_front() {
|
||||
BOOST_CB_ASSERT(!empty()); // check for empty buffer (front element not available)
|
||||
@@ -2082,15 +1986,15 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
//! 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) {
|
||||
m_first = m_last = m_buff = allocate(capacity);
|
||||
m_end = m_buff + capacity;
|
||||
}
|
||||
|
||||
//! Initialize the internal buffer.
|
||||
void initialize_buffer(capacity_type buffer_capacity, param_value_type item) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
//! Initialize the circular buffer.
|
||||
void initialize(capacity_type capacity, param_value_type item) {
|
||||
initialize(capacity);
|
||||
BOOST_TRY {
|
||||
cb_details::uninitialized_fill_n_with_alloc(m_buff, size(), item, m_alloc);
|
||||
} BOOST_CATCH(...) {
|
||||
@@ -2104,8 +2008,7 @@ private:
|
||||
template <class IntegralType>
|
||||
void initialize(IntegralType n, IntegralType item, const true_type&) {
|
||||
m_size = static_cast<size_type>(n);
|
||||
initialize_buffer(size(), item);
|
||||
m_first = m_last = m_buff;
|
||||
initialize(size(), item);
|
||||
}
|
||||
|
||||
//! Specialized initialize method.
|
||||
@@ -2139,35 +2042,32 @@ private:
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class IntegralType>
|
||||
void initialize(capacity_type buffer_capacity, IntegralType n, IntegralType item, const true_type&) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= static_cast<size_type>(n)); // check for capacity lower than n
|
||||
void initialize(capacity_type capacity, IntegralType n, IntegralType item, const true_type&) {
|
||||
BOOST_CB_ASSERT(capacity >= static_cast<size_type>(n)); // check for capacity lower than n
|
||||
m_size = static_cast<size_type>(n);
|
||||
initialize_buffer(buffer_capacity, item);
|
||||
m_first = m_buff;
|
||||
m_last = buffer_capacity == size() ? m_buff : m_buff + size();
|
||||
initialize(capacity, item);
|
||||
}
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class Iterator>
|
||||
void initialize(capacity_type buffer_capacity, Iterator first, Iterator last, const false_type&) {
|
||||
void initialize(capacity_type capacity, Iterator first, Iterator last, const false_type&) {
|
||||
BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
initialize(buffer_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
initialize(capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
initialize(capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class InputIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const std::input_iterator_tag&) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
m_first = m_last = m_buff;
|
||||
initialize(capacity);
|
||||
m_size = 0;
|
||||
if (buffer_capacity == 0)
|
||||
if (capacity == 0)
|
||||
return;
|
||||
while (first != last && !full()) {
|
||||
m_alloc.construct(m_last, *first++);
|
||||
@@ -2183,37 +2083,36 @@ private:
|
||||
|
||||
//! Specialized initialize method.
|
||||
template <class ForwardIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
const std::forward_iterator_tag&) {
|
||||
BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range
|
||||
initialize(buffer_capacity, first, last, std::distance(first, last));
|
||||
initialize(capacity, first, last, std::distance(first, last));
|
||||
}
|
||||
|
||||
//! Initialize the circular buffer.
|
||||
//! Helper initialize method.
|
||||
template <class ForwardIterator>
|
||||
void initialize(capacity_type buffer_capacity,
|
||||
void initialize(capacity_type capacity,
|
||||
ForwardIterator first,
|
||||
ForwardIterator last,
|
||||
size_type distance) {
|
||||
initialize_buffer(buffer_capacity);
|
||||
m_first = m_buff;
|
||||
if (distance > buffer_capacity) {
|
||||
std::advance(first, distance - buffer_capacity);
|
||||
m_size = buffer_capacity;
|
||||
initialize(capacity);
|
||||
if (distance > capacity) {
|
||||
std::advance(first, distance - capacity);
|
||||
m_size = capacity;
|
||||
} else {
|
||||
m_size = distance;
|
||||
if (distance != capacity)
|
||||
m_last = m_buff + size();
|
||||
}
|
||||
BOOST_TRY {
|
||||
m_last = cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc);
|
||||
cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc);
|
||||
} BOOST_CATCH(...) {
|
||||
deallocate(m_buff, buffer_capacity);
|
||||
deallocate(m_buff, capacity);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
if (m_last == m_end)
|
||||
m_last = m_buff;
|
||||
}
|
||||
|
||||
//! Reset the circular buffer.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Debug support for the circular buffer library.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Helper classes and functions for the circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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,6 +66,16 @@ 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.
|
||||
@@ -131,7 +141,7 @@ private:
|
||||
};
|
||||
|
||||
/*!
|
||||
\class capacity_control
|
||||
\struct capacity_control
|
||||
\brief Capacity controller of the space optimized circular buffer.
|
||||
*/
|
||||
template <class Size>
|
||||
@@ -146,9 +156,9 @@ class capacity_control {
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
capacity_control(Size buffer_capacity, Size min_buffer_capacity = 0)
|
||||
: m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity); // check for capacity lower than min_capacity
|
||||
capacity_control(Size capacity, Size min_capacity = 0)
|
||||
: m_capacity(capacity), m_min_capacity(min_capacity) {
|
||||
BOOST_CB_ASSERT(capacity >= min_capacity); // check for capacity lower than min_capacity
|
||||
}
|
||||
|
||||
// Default copy constructor.
|
||||
@@ -166,7 +176,7 @@ public:
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct iterator
|
||||
\class iterator
|
||||
\brief Random access iterator for the circular buffer.
|
||||
\param Buff The type of the underlying circular buffer.
|
||||
\param Traits Basic iterator types.
|
||||
@@ -174,7 +184,7 @@ public:
|
||||
for iterating from begin() to end() of the circular buffer.
|
||||
*/
|
||||
template <class Buff, class Traits>
|
||||
struct iterator :
|
||||
class iterator :
|
||||
public boost::iterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename Traits::value_type,
|
||||
@@ -185,6 +195,7 @@ struct iterator :
|
||||
, public debug_iterator_base
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
{
|
||||
private:
|
||||
// Helper types
|
||||
|
||||
//! Base iterator.
|
||||
@@ -198,6 +209,7 @@ struct iterator :
|
||||
//! 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.
|
||||
@@ -215,6 +227,9 @@ struct iterator :
|
||||
//! Difference type.
|
||||
typedef typename base_iterator::difference_type difference_type;
|
||||
|
||||
#if !defined(BOOST_CB_TEST) && BOOST_CB_ENABLE_DEBUG == 0
|
||||
private:
|
||||
#endif
|
||||
// Member variables
|
||||
|
||||
//! The circular buffer where the iterator points to.
|
||||
@@ -223,6 +238,7 @@ struct iterator :
|
||||
//! An internal iterator.
|
||||
pointer m_it;
|
||||
|
||||
public:
|
||||
// Construction & assignment
|
||||
|
||||
// Default copy constructor.
|
||||
@@ -274,11 +290,16 @@ struct iterator :
|
||||
pointer operator -> () const { return &(operator*()); }
|
||||
|
||||
//! Difference operator.
|
||||
template <class Traits0>
|
||||
difference_type operator - (const iterator<Buff, Traits0>& it) const {
|
||||
difference_type operator - (const iterator& 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 linearize_pointer(*this) - linearize_pointer(it);
|
||||
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;
|
||||
}
|
||||
|
||||
//! Increment operator (prefix).
|
||||
@@ -336,7 +357,7 @@ struct iterator :
|
||||
iterator& operator -= (difference_type n) {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
if (n > 0) {
|
||||
BOOST_CB_ASSERT(*this - m_buff->begin() >= n); // check for too large n
|
||||
BOOST_CB_ASSERT(m_buff->begin() - *this <= -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;
|
||||
@@ -373,12 +394,12 @@ struct iterator :
|
||||
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 linearize_pointer(*this) < linearize_pointer(it);
|
||||
return less(create_helper_pointer(*this), create_helper_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>
|
||||
@@ -388,14 +409,44 @@ struct iterator :
|
||||
template <class Traits0>
|
||||
bool operator >= (const iterator<Buff, Traits0>& it) const { return !(*this < it); }
|
||||
|
||||
private:
|
||||
// Helpers
|
||||
|
||||
//! Get a pointer which would point to the same element as the iterator in case the circular buffer is linearized.
|
||||
//! Create helper pointer.
|
||||
template <class Traits0>
|
||||
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));
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Implementation of the circular buffer adaptor.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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,8 +90,6 @@ 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;
|
||||
@@ -152,8 +150,7 @@ public:
|
||||
Does not invalidate any iterators.
|
||||
\par Complexity
|
||||
Constant (in the size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>,
|
||||
<code>set_capacity(const capacity_type&)</code>
|
||||
\sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
const capacity_type& capacity() const { return m_capacity_ctrl; }
|
||||
|
||||
@@ -194,8 +191,7 @@ public:
|
||||
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>,
|
||||
<code>\link resize() resize(size_type, const_reference)\endlink</code>
|
||||
\sa <code>rset_capacity()</code>, <code>resize()</code>
|
||||
*/
|
||||
void set_capacity(const capacity_type& capacity_ctrl) {
|
||||
m_capacity_ctrl = capacity_ctrl;
|
||||
@@ -230,8 +226,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the new size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>\link rresize() rresize(size_type, const_reference)\endlink</code>,
|
||||
<code>set_capacity(const capacity_type&)</code>
|
||||
\sa <code>rresize()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
void resize(size_type new_size, param_value_type item = value_type()) {
|
||||
if (new_size > size()) {
|
||||
@@ -265,8 +260,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in <code>min[size(), capacity_ctrl.%capacity()]</code>).
|
||||
\sa <code>set_capacity(const capacity_type&)</code>,
|
||||
<code>\link rresize() rresize(size_type, const_reference)\endlink</code>
|
||||
\sa <code>set_capacity()</code>, <code>rresize()</code>
|
||||
*/
|
||||
void rset_capacity(const capacity_type& capacity_ctrl) {
|
||||
m_capacity_ctrl = capacity_ctrl;
|
||||
@@ -301,8 +295,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the new size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>\link resize() resize(size_type, const_reference)\endlink</code>,
|
||||
<code>rset_capacity(const capacity_type&)</code>
|
||||
\sa <code>rresize()</code>, <code>set_capacity()</code>
|
||||
*/
|
||||
void rresize(size_type new_size, param_value_type item = value_type()) {
|
||||
if (new_size > size()) {
|
||||
@@ -314,19 +307,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! Create an empty space optimized circular buffer with zero capacity.
|
||||
//! Create an empty space optimized circular buffer with a maximum capacity.
|
||||
/*!
|
||||
\post <code>capacity().%capacity() == 0 \&\& capacity().min_capacity() == 0 \&\& size() == 0</code>
|
||||
\post <code>capacity().%capacity() == max_size() \&\& capacity().min_capacity() == 0 \&\& size() == 0</code>
|
||||
<br><br>There is no memory allocated in the internal buffer.
|
||||
\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(0) {}
|
||||
, m_capacity_ctrl(max_size()) {}
|
||||
|
||||
//! Create an empty space optimized circular buffer with the specified capacity.
|
||||
/*!
|
||||
@@ -725,8 +717,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>\link push_front() push_front(const_reference)\endlink</code>, <code>pop_back()</code>,
|
||||
<code>pop_front()</code>
|
||||
\sa <code>push_front()</code>, <code>pop_back()</code>, <code>pop_front()</code>
|
||||
*/
|
||||
void push_back(param_value_type item = value_type()) {
|
||||
check_low_capacity();
|
||||
@@ -750,8 +741,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>\link push_back() push_back(const_reference)\endlink</code>, <code>pop_back()</code>,
|
||||
<code>pop_front()</code>
|
||||
\sa <code>push_back()</code>, <code>pop_back()</code>, <code>pop_front()</code>
|
||||
*/
|
||||
void push_front(param_value_type item = value_type()) {
|
||||
check_low_capacity();
|
||||
@@ -772,8 +762,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>pop_front()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>,
|
||||
<code>\link push_front() push_front(const_reference)\endlink</code>
|
||||
\sa <code>pop_front()</code>, <code>push_back()</code>, <code>push_front()</code>
|
||||
*/
|
||||
void pop_back() {
|
||||
circular_buffer<T, Alloc>::pop_back();
|
||||
@@ -794,8 +783,7 @@ public:
|
||||
equal to <code>end()</code>).
|
||||
\par Complexity
|
||||
Linear (in the size of the <code>circular_buffer_space_optimized</code>).
|
||||
\sa <code>pop_back()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>,
|
||||
<code>\link push_front() push_front(const_reference)\endlink</code>
|
||||
\sa <code>pop_back()</code>, <code>push_back()</code>, <code>push_front()</code>
|
||||
*/
|
||||
void pop_front() {
|
||||
circular_buffer<T, Alloc>::pop_front();
|
||||
@@ -1229,8 +1217,8 @@ private:
|
||||
}
|
||||
|
||||
//! Ensure the reserve for possible growth up.
|
||||
size_type ensure_reserve(size_type new_capacity, size_type buffer_size) const {
|
||||
if (buffer_size + new_capacity / 5 >= new_capacity)
|
||||
size_type ensure_reserve(size_type new_capacity, size_type size) const {
|
||||
if (size + new_capacity / 5 >= new_capacity)
|
||||
new_capacity *= 2; // ensure at least 20% reserve
|
||||
if (new_capacity > m_capacity_ctrl)
|
||||
return m_capacity_ctrl;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Forward declaration of the circular buffer and its adaptor.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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
|
||||
|
||||
@@ -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-2008 Jan Gaspar</small>
|
||||
<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>
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
# Boost circular_buffer test Jamfile.
|
||||
#
|
||||
# Copyright (c) 2003-2008 Jan Gaspar
|
||||
# Copyright (c) 2003-2007 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 : ]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Test of the base circular buffer container.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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,7 +61,6 @@ 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);
|
||||
@@ -190,6 +189,7 @@ 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,62 +506,6 @@ 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)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Comparison of bounded buffers based on different containers.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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,7 +12,6 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <deque>
|
||||
@@ -30,11 +29,10 @@ public:
|
||||
typedef boost::circular_buffer<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -72,11 +70,10 @@ public:
|
||||
typedef boost::circular_buffer_space_optimized<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -114,11 +111,10 @@ public:
|
||||
typedef std::deque<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
@@ -157,11 +153,10 @@ public:
|
||||
typedef std::list<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
void push_front(const value_type& item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
|
||||
176
test/common.ipp
176
test/common.ipp
@@ -1,6 +1,6 @@
|
||||
// Common tests for the circular buffer and its adaptor.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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,16 +328,8 @@ 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]
|
||||
@@ -357,9 +349,7 @@ 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]
|
||||
@@ -378,9 +368,7 @@ 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]
|
||||
@@ -396,9 +384,7 @@ 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]
|
||||
@@ -410,7 +396,6 @@ 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]
|
||||
@@ -419,7 +404,6 @@ 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);
|
||||
@@ -427,7 +411,6 @@ void linearize_test() {
|
||||
generic_test(cb4);
|
||||
generic_test(cb5);
|
||||
generic_test(cb6);
|
||||
generic_test(cb7);
|
||||
}
|
||||
|
||||
void array_range_test() {
|
||||
@@ -786,17 +769,6 @@ 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;
|
||||
@@ -808,7 +780,6 @@ 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);
|
||||
@@ -832,29 +803,19 @@ 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> cb7(MyInputIterator(v.begin()), MyInputIterator(v.end()));
|
||||
CB_CONTAINER<int> cb8(3, MyInputIterator(v.begin()), MyInputIterator(v.end()));
|
||||
CB_CONTAINER<int> cb6(MyInputIterator(v.begin()), MyInputIterator(v.end()));
|
||||
CB_CONTAINER<int> cb7(3, MyInputIterator(v.begin()), MyInputIterator(v.end()));
|
||||
|
||||
BOOST_CHECK(cb7.capacity() == 5);
|
||||
BOOST_CHECK(cb8.capacity() == 3);
|
||||
BOOST_CHECK(cb6.capacity() == 5);
|
||||
BOOST_CHECK(cb7.capacity() == 3);
|
||||
|
||||
#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
|
||||
@@ -863,7 +824,6 @@ void constructor_test() {
|
||||
generic_test(cb3);
|
||||
generic_test(cb4);
|
||||
generic_test(cb5);
|
||||
generic_test(cb6);
|
||||
}
|
||||
|
||||
void assign_test() {
|
||||
@@ -934,9 +894,6 @@ 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();
|
||||
@@ -944,7 +901,6 @@ 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);
|
||||
@@ -955,16 +911,11 @@ 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() {
|
||||
@@ -1830,122 +1781,6 @@ 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;
|
||||
|
||||
@@ -1993,5 +1828,4 @@ 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));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Note: The soft iterator invalidation definition CAN NOT be applied
|
||||
// to the space optimized circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Test of the space optimized adaptor of the circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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 specific_constructors_test() {
|
||||
void some_constructors_test() {
|
||||
|
||||
cb_space_optimized cb1;
|
||||
BOOST_CHECK(cb1.capacity() == 0);
|
||||
BOOST_CHECK(cb1.capacity() == cb1.max_size());
|
||||
BOOST_CHECK(cb1.capacity().min_capacity() == 0);
|
||||
BOOST_CHECK(cb1.internal_capacity() == 0);
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
@@ -90,15 +90,10 @@ void specific_constructors_test() {
|
||||
cb1.push_back(2);
|
||||
cb1.push_back(3);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
BOOST_CHECK(cb1.capacity() == 0);
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1.capacity() == cb1.max_size());
|
||||
|
||||
vector<int> v;
|
||||
v.push_back(1);
|
||||
v.push_back(2);
|
||||
v.push_back(3);
|
||||
|
||||
cb_space_optimized cb2(v.begin(), v.end());
|
||||
cb_space_optimized cb2(cb1.begin(), cb1.end());
|
||||
|
||||
BOOST_CHECK(cb2.capacity() == 3);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() == 0);
|
||||
@@ -188,7 +183,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(&specific_constructors_test));
|
||||
tests->add(BOOST_TEST_CASE(&some_constructors_test));
|
||||
tests->add(BOOST_TEST_CASE(&shrink_to_fit_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_invalidation_test));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Header file for the test of the circular buffer library.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2003-2007 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
|
||||
|
||||
Reference in New Issue
Block a user