mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-09 23:12:25 +00:00
Fix for VC6, updated TODO, source formatting.
[SVN r2592]
This commit is contained in:
78
doc/Doxyfile
78
doc/Doxyfile
@@ -11,12 +11,12 @@ OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
@@ -24,7 +24,7 @@ DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
@@ -52,11 +52,11 @@ GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -66,7 +66,7 @@ WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -76,13 +76,13 @@ RECURSIVE = YES
|
||||
EXCLUDE = ../../../boost/circular_buffer/debug.hpp \
|
||||
../../../boost/circular_buffer/details.hpp
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
@@ -98,20 +98,20 @@ VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = NO
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
@@ -128,8 +128,8 @@ LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
@@ -141,8 +141,8 @@ GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -155,8 +155,8 @@ MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = YES
|
||||
XML_OUTPUT = .
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
@@ -168,29 +168,29 @@ GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = NO
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
PERL_PATH =
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
HIDE_UNDOC_RELATIONS = NO
|
||||
@@ -206,8 +206,8 @@ CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
@@ -216,6 +216,6 @@ DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
|
||||
44
doc/TODO
44
doc/TODO
@@ -6,7 +6,8 @@ t02 DONE
|
||||
docs: paragraph "Rationale": remove the "producer-consumer" usage (it is
|
||||
confusing)
|
||||
|
||||
t03 docs: "Friend Functions" should be rather "Standalone Functions"
|
||||
t03 DONE
|
||||
docs: "Friend Functions" should be rather "Standalone Functions"
|
||||
and should mention swap, <=, >= as well
|
||||
|
||||
t04 DONE
|
||||
@@ -21,9 +22,11 @@ t06 docs: define the element type requirements (as a precondition) for every
|
||||
|
||||
t07 adaptor.hpp: fix needed to compile the test with BCB 6.4
|
||||
|
||||
t08 base_test.cpp: fix needed to compile with VC 6.5
|
||||
t08 DONE
|
||||
base_test.cpp: fix needed to compile with VC 6.5
|
||||
|
||||
t09 fix needed to compile the tests with GCC 3.4
|
||||
t09 DONE
|
||||
fix needed to compile the tests with GCC 3.4
|
||||
|
||||
t10 docs: define exception safety for every method
|
||||
"Guarantee of basic exception safety" as a design criteria for the whole
|
||||
@@ -44,7 +47,7 @@ t14 docs: explicitly document methods which do not throw any exception,
|
||||
e.g. "Exceptions: none"
|
||||
|
||||
t15 rename the data() method to something meaningful concerning its mutation
|
||||
status; mention its linear complexity in the docs REFINE!!!
|
||||
status (e.g to_array); mention its linear complexity in the docs
|
||||
|
||||
t16 docs: document that push_back() or other methods that they can choose NOT
|
||||
to insert something -> in general document the boundary conditions
|
||||
@@ -55,16 +58,20 @@ t17 docs: delete the "Semantics" paragraph and move its content directly
|
||||
|
||||
t18 Perhaps in addition to a data() function, it would be useful if the
|
||||
container provided constant-time access to the data as two arrays.
|
||||
Perhaps something like std::pair<T *, T *> first_range() and
|
||||
std::pair<T *, T *> second_range(). REFINE!!!
|
||||
Perhaps something like std::pair<T *, T *> array_1() and
|
||||
std::pair<T *, T *> array_2(). (Consider also returning of
|
||||
std::pair<T *, size_t>.)
|
||||
|
||||
t19 docs: merge the source documentation with the main documentation
|
||||
t19 DONE
|
||||
docs: merge the source documentation with the main documentation
|
||||
|
||||
t20 docs: define requirements on the Alloc type parameter
|
||||
|
||||
t21 docs: consider better documentation for the "overwrite" term
|
||||
t21 docs: consider better documentation for the "overwrite" term; add glossary
|
||||
section
|
||||
|
||||
t22 implement a "hook" for the overwrite operation (maybe as an adaptor)
|
||||
t22 DEPRIVED
|
||||
implement a "hook" for the overwrite operation (maybe as an adaptor)
|
||||
|
||||
t23 amend the source code according to the formal review (line 1578); use
|
||||
the new iterator if possible
|
||||
@@ -75,29 +82,31 @@ t24 ammend the test in order to compile with the new iterator if really
|
||||
t25 add constructor taking just two iterators as a parameter
|
||||
|
||||
t26 change the current implementation of "overwrite" operation -> overwrite
|
||||
will be equivalent to assign; adaptor can change the meaning of overwrite
|
||||
operation (to destruct/construct) REFINE!!!
|
||||
will be equivalent to assign
|
||||
|
||||
t27 docs: apply the DefaultConstructible and Assignable type requirements
|
||||
|
||||
t28 docs: the difference between resize() and set_capacity() should be
|
||||
mentioned more explicitly
|
||||
|
||||
t29 add rerase method REFINE!!!
|
||||
t29 DONE
|
||||
add rerase methods
|
||||
|
||||
t30 The insert() function has its rinsert() counterpart. The same issue
|
||||
for resize and set_capacity is solved with the boolean parameter
|
||||
remove_front, which is not consistent. CONSIDER!!!
|
||||
remove_front, which is not consistent.
|
||||
|
||||
t31 docs: "... According to the semantics of rinsert, insertion overwrites
|
||||
front-most items as necessary ..." should probably read "back-most items"
|
||||
if this is a valid english word
|
||||
|
||||
t32 CONSIDER!!! reimplementing the comparison functions (line 3801)
|
||||
t32 DEPRIVED
|
||||
reimplementing the comparison functions (line 3801)
|
||||
|
||||
t33 fix needed to compile the tests with Comeau 4.3.0 compiler
|
||||
|
||||
t34 CONSIDER!!! throwing exception when push_back() to empty container
|
||||
t34 DEPRIVED
|
||||
consider throwing exception when pop_back() an empty container
|
||||
|
||||
t35 docs: there should be warning for data() documentation that the returned
|
||||
pointer gets very easily invalidated
|
||||
@@ -124,6 +133,11 @@ t42 documentation may add some rationale on its internal data structures
|
||||
|
||||
t43 adaptor.hpp: apply workaround for borland (line 5764)
|
||||
|
||||
t44 add some "post tests" after testing non-const methods (such as inserting
|
||||
an element into container which is tested for erase)
|
||||
|
||||
t55 ammend the file header text (remove the reference to the accompanying file
|
||||
LICENSE_1_0.txt)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2,70 +2,70 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
|
||||
<title>Templated Circular Buffer Container</title>
|
||||
</head>
|
||||
<body bgcolor="#ffffff">
|
||||
<table id="title" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h1>Templated Circular Buffer Container</h1>
|
||||
<h1>circular_buffer<T, Alloc></h1>
|
||||
</td>
|
||||
<td><a href="http://boost.org"><IMG height=86 alt=Boost src="../../../c++boost.gif" width=277 border=0></a></td>
|
||||
</tr>
|
||||
<h1>Templated Circular Buffer Container</h1>
|
||||
<h1>circular_buffer<T, Alloc></h1>
|
||||
</td>
|
||||
<td><a href="http://boost.org"><IMG height=86 alt=Boost src="../../../c++boost.gif" width=277 border=0></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Contents</h2>
|
||||
<A href="#description">Description</A><br>
|
||||
<A href="#simpleexample">Simple Example</A><br>
|
||||
<A href="#synopsis">Synopsis</A><br>
|
||||
<A href="#rationale">Rationale</A><br>
|
||||
<A href="#header">Header files</A><br>
|
||||
<A href="#model">Modeled concepts</A><br>
|
||||
<A href="#parameters">Template Parameters</A><br>
|
||||
<A href="#types">Public Types</A><br>
|
||||
<A href="#constructors">Constructors & Destructor</A><br>
|
||||
<A href="#methods">Public Member Functions</A><br>
|
||||
<A href="#functions">Standalone Functions</A><br>
|
||||
<A href="#semantics">Semantics</A><br>
|
||||
<A href="#caveats">Caveats</A><br>
|
||||
<A href="#debug">Debug Support</A><br>
|
||||
<A href="#example">Example</A><br>
|
||||
<A href="#notes">Notes</A><br>
|
||||
<A href="#see">See also</A><br>
|
||||
<A href="#ideas">Ideas for Future Improvements</A><br>
|
||||
<A href="#ack">Acknowledgments</A>
|
||||
<A href="#description">Description</A><br>
|
||||
<A href="#simpleexample">Simple Example</A><br>
|
||||
<A href="#synopsis">Synopsis</A><br>
|
||||
<A href="#rationale">Rationale</A><br>
|
||||
<A href="#header">Header files</A><br>
|
||||
<A href="#model">Modeled concepts</A><br>
|
||||
<A href="#parameters">Template Parameters</A><br>
|
||||
<A href="#types">Public Types</A><br>
|
||||
<A href="#constructors">Constructors & Destructor</A><br>
|
||||
<A href="#methods">Public Member Functions</A><br>
|
||||
<A href="#functions">Standalone Functions</A><br>
|
||||
<A href="#semantics">Semantics</A><br>
|
||||
<A href="#caveats">Caveats</A><br>
|
||||
<A href="#debug">Debug Support</A><br>
|
||||
<A href="#example">Example</A><br>
|
||||
<A href="#notes">Notes</A><br>
|
||||
<A href="#see">See also</A><br>
|
||||
<A href="#ideas">Ideas for Future Improvements</A><br>
|
||||
<A href="#ack">Acknowledgments</A>
|
||||
<table id="table_figure" border="0" align="right">
|
||||
<tr>
|
||||
<td><IMG height=332 alt="Circular Buffer" src="circular_buffer.png" width=300 ></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="300">
|
||||
<table id="table_figure_desc" align="right" border="0" cellpadding="5"><tr>
|
||||
<table id="table_figure_desc" align="right" border="0" cellpadding="5"><tr>
|
||||
<td valign="top"><b>Figure:</b></td>
|
||||
<td valign="top">The circular buffer (for someone known as ring or cyclic buffer).</td>
|
||||
</tr></table>
|
||||
<td valign="top">The circular buffer (for someone known as ring or cyclic buffer).</td>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>
|
||||
<a name="description">Description</a>
|
||||
</h2>
|
||||
<p>The <code>circular_buffer</code> container provides fixed capacity storage with
|
||||
constant time insertion and removal of elements at each end of a circular
|
||||
buffer. When the capacity of the <code>circular_buffer</code> is exhausted,
|
||||
inserted elements will cause elements at the opposite end to be overwritten (see the Figure).
|
||||
The <code>circular_buffer</code> only allocates memory when
|
||||
created, when the capacity is adjusted explicitly, or as necessary to
|
||||
accommodate a resizing or assign operation. (There is also a <code><A href="circular_buffer_space_optimized.html">circular_buffer_space_optimized</A>
|
||||
</code>available. It is an adaptor of the <code>circular_buffer</code>
|
||||
which does not allocate memory at once when created rather it allocates memory as needed.)
|
||||
</p>
|
||||
<p>The <code>circular_buffer</code> container provides fixed capacity storage with
|
||||
constant time insertion and removal of elements at each end of a circular
|
||||
buffer. When the capacity of the <code>circular_buffer</code> is exhausted,
|
||||
inserted elements will cause elements at the opposite end to be overwritten (see the Figure).
|
||||
The <code>circular_buffer</code> only allocates memory when
|
||||
created, when the capacity is adjusted explicitly, or as necessary to
|
||||
accommodate a resizing or assign operation. (There is also a <code><A href="circular_buffer_space_optimized.html">circular_buffer_space_optimized</A>
|
||||
</code>available. It is an adaptor of the <code>circular_buffer</code>
|
||||
which does not allocate memory at once when created rather it allocates memory as needed.)
|
||||
</p>
|
||||
<h2>
|
||||
<a name="simpleexample">Simple Example</a>
|
||||
</h2>
|
||||
<p>A brief example using the <code>circular_buffer</code>:
|
||||
</p>
|
||||
</p>
|
||||
<pre> #include <boost/circular_buffer.hpp>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@@ -79,7 +79,7 @@
|
||||
|
||||
// The buffer is full now, pushing subsequent
|
||||
// elements will overwrite the front-most elements.
|
||||
|
||||
|
||||
cb.push_back(4); // Overwrite 1 with 4.
|
||||
cb.push_back(5); // Overwrite 2 with 5.
|
||||
|
||||
@@ -125,11 +125,11 @@ public:
|
||||
typedef typename Alloc::value_type <A href="#classboost_1_1circular__buffer_1w13">value_type</A>;
|
||||
|
||||
template <class InputIterator>
|
||||
<A href="#classboost_1_1circular__buffer_1a9">circular_buffer</A>(size_type capacity,
|
||||
InputIterator first, InputIterator last,
|
||||
<A href="#classboost_1_1circular__buffer_1a9">circular_buffer</A>(size_type capacity,
|
||||
InputIterator first, InputIterator last,
|
||||
const allocator_type& alloc = allocator_type());
|
||||
<A href="#classboost_1_1circular__buffer_1a10">circular_buffer</A>(const circular_buffer<T,Alloc>& cb);
|
||||
<A href="#classboost_1_1circular__buffer_1a11">circular_buffer</A>(size_type capacity,
|
||||
<A href="#classboost_1_1circular__buffer_1a11">circular_buffer</A>(size_type capacity,
|
||||
value_type item, const allocator_type& alloc = allocator_type());
|
||||
explicit <A href="#classboost_1_1circular__buffer_1a12">circular_buffer</A>(size_type capacity, const allocator_type& alloc = allocator_type());
|
||||
<A href="#classboost_1_1circular__buffer_1a51">~circular_buffer</A>();
|
||||
@@ -210,84 +210,84 @@ template <class T, class Alloc>
|
||||
<h2>
|
||||
<a name="rationale">Rationale</a>
|
||||
</h2>
|
||||
<p>A contiguous region of memory utilized as a circular buffer has several unique
|
||||
and useful characteristics:
|
||||
</p>
|
||||
<p>A contiguous region of memory utilized as a circular buffer has several unique
|
||||
and useful characteristics:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
Fixed memory use and no implicit or unexpected memory
|
||||
allocation.
|
||||
|
||||
Fixed memory use and no implicit or unexpected memory
|
||||
allocation.
|
||||
|
||||
<li>
|
||||
Fast constant-time insertion and removal of elements
|
||||
from the front and back.
|
||||
|
||||
Fast constant-time insertion and removal of elements
|
||||
from the front and back.
|
||||
|
||||
<li>
|
||||
Fast constant-time random access of elements.
|
||||
|
||||
Fast constant-time random access of elements.
|
||||
|
||||
<li>
|
||||
Suitability for real-time and performance critical applications.
|
||||
</li>
|
||||
</ol>
|
||||
Suitability for real-time and performance critical applications.
|
||||
</li>
|
||||
</ol>
|
||||
<p>The <code>circular_buffer</code> container provides a similar interface to <code>std::vector</code>,
|
||||
<code>std::deque</code> and <code>std::list</code> including <code>push</code>, <code>
|
||||
pop</code>, <code>insert</code>, <code>erase</code>, iterators and
|
||||
compatibility with <code>std</code> algorithms.
|
||||
</p>
|
||||
<code>std::deque</code> and <code>std::list</code> including <code>push</code>, <code>
|
||||
pop</code>, <code>insert</code>, <code>erase</code>, iterators and
|
||||
compatibility with <code>std</code> algorithms.
|
||||
</p>
|
||||
<p>Possible applications of the <code>circular_buffer</code> include:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Storage of the most recently received samples,
|
||||
overwriting the oldest as new samples arrive.
|
||||
|
||||
Storage of the most recently received samples,
|
||||
overwriting the oldest as new samples arrive.
|
||||
|
||||
<li>
|
||||
Efficient fixed capacity FIFO (First In, First Out)
|
||||
queue.
|
||||
|
||||
Efficient fixed capacity FIFO (First In, First Out)
|
||||
queue.
|
||||
|
||||
<li>
|
||||
Efficient fixed capacity LIFO (Last In, First Out) queue.
|
||||
</li>
|
||||
</ul>
|
||||
<p>The design of the <code>circular_buffer</code> container is guided by the
|
||||
following principles:
|
||||
</p>
|
||||
Efficient fixed capacity LIFO (Last In, First Out) queue.
|
||||
</li>
|
||||
</ul>
|
||||
<p>The design of the <code>circular_buffer</code> container is guided by the
|
||||
following principles:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
Maximum <em>efficiency</em> for
|
||||
envisaged applications.
|
||||
Maximum <em>efficiency</em> for
|
||||
envisaged applications.
|
||||
<li>
|
||||
Suitable for <em>general purpose</em> use.
|
||||
Suitable for <em>general purpose</em> use.
|
||||
<li>
|
||||
<em>Interoperable</em> with other <code>std</code> containers and algorithms.
|
||||
<em>Interoperable</em> with other <code>std</code> containers and algorithms.
|
||||
<li>
|
||||
The behaviour of the buffer as <em>intuitive</em> as possible.
|
||||
The behaviour of the buffer as <em>intuitive</em> as possible.
|
||||
<li>
|
||||
Suitable for <em>specialization</em> by means of adaptors. (The <code><A href="circular_buffer_space_optimized.html">circular_buffer_space_optimized</A>
|
||||
</code>is such an example of the adaptor.)
|
||||
Suitable for <em>specialization</em> by means of adaptors. (The <code><A href="circular_buffer_space_optimized.html">circular_buffer_space_optimized</A>
|
||||
</code>is such an example of the adaptor.)
|
||||
<li>
|
||||
Guarantee of <em>basic exception safety</em>.</li>
|
||||
Guarantee of <em>basic exception safety</em>.</li>
|
||||
</ol>
|
||||
<h2>
|
||||
<a name="header">Header files</a>
|
||||
</h2>
|
||||
<p>
|
||||
The <code>circular_buffer</code> is defined in the file
|
||||
The <code>circular_buffer</code> is defined in the file
|
||||
<code><A href="../../../boost/circular_buffer.hpp">boost/circular_buffer.hpp</A></code>.
|
||||
There is also a forward declaration for the <code>circular_buffer</code> in the header file
|
||||
<code><A href="../../../boost/circular_buffer_fwd.hpp">boost/circular_buffer_fwd.hpp</A></code>.
|
||||
</p>
|
||||
</p>
|
||||
<h2>
|
||||
<a name="model">Modeled concepts</a>
|
||||
</h2>
|
||||
<p><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">Random Access
|
||||
Container</a>, <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
Front Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
Back Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
Assignable</a> (SGI specific), <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">
|
||||
Equality Comparable</a>, <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">
|
||||
LessThan Comparable</a> (SGI specific)
|
||||
</p>
|
||||
<p><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">Random Access
|
||||
Container</a>, <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
Front Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
Back Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
Assignable</a> (SGI specific), <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">
|
||||
Equality Comparable</a>, <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">
|
||||
LessThan Comparable</a> (SGI specific)
|
||||
</p>
|
||||
<h2>
|
||||
<a name="parameters">Template Parameters</a>
|
||||
</h2>
|
||||
@@ -453,7 +453,7 @@ The type of the elements stored in the circular buffer. </td>
|
||||
<code>
|
||||
<b>
|
||||
template <class InputIterator><br>
|
||||
circular_buffer(<A href="#classboost_1_1circular__buffer_1w12">size_type</A> capacity, <br>
|
||||
circular_buffer(<A href="#classboost_1_1circular__buffer_1w12">size_type</A> capacity, <br>
|
||||
InputIterator first, InputIterator last, <br> const <A href="#classboost_1_1circular__buffer_1w0">allocator_type</A>& alloc = allocator_type());</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -516,7 +516,7 @@ Create a full circular buffer with a given capacity and filled with copies of <c
|
||||
<table id="table_post_desc_id4488197"><tr>
|
||||
<td valign="top"><b>Postcondition:</b></td>
|
||||
<td>
|
||||
<code>(*this).<A href="#classboost_1_1circular__buffer_1a49">size()</A>
|
||||
<code>(*this).<A href="#classboost_1_1circular__buffer_1a49">size()</A>
|
||||
== capacity && (*this)[0] == (*this)[1] == ... == (*this).<A href="#classboost_1_1circular__buffer_1a5">back()</A> == item</code> </td>
|
||||
</tr></table> </td>
|
||||
</tr>
|
||||
@@ -575,7 +575,7 @@ Destructor. </td></tr></table>
|
||||
<a name="classboost_1_1circular__buffer_1a0"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class InputIterator><br>
|
||||
template <class InputIterator><br>
|
||||
void assign(InputIterator first, InputIterator last);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -802,7 +802,7 @@ Erase all the stored elements. </td></tr></table>
|
||||
<td>
|
||||
<table id="table_detailed_desc_id4488823"><tr><td>
|
||||
Return pointer to data stored in the circular buffer as a continuous array of values. </td></tr></table>
|
||||
<table id="table_detailed_desc_id4488833"><tr><td>This method can be useful e.g. when passing the stored data into the legacy C API.
|
||||
<table id="table_detailed_desc_id4488833"><tr><td>This method can be useful e.g. when passing the stored data into the legacy C API.
|
||||
|
||||
|
||||
|
||||
@@ -1063,7 +1063,7 @@ Return the allocator. </td></tr></table>
|
||||
<code>
|
||||
<b>
|
||||
template <class InputIterator><br>
|
||||
void insert(<A href="#classboost_1_1circular__buffer_1w6">iterator</A> pos,
|
||||
void insert(<A href="#classboost_1_1circular__buffer_1w6">iterator</A> pos,
|
||||
InputIterator first, InputIterator last);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1559,7 +1559,7 @@ Change the size of the circular buffer. </td></tr></table>
|
||||
<code>
|
||||
<b>
|
||||
template <class InputIterator><br>
|
||||
void rinsert(<A href="#classboost_1_1circular__buffer_1w6">iterator</A> pos,
|
||||
void rinsert(<A href="#classboost_1_1circular__buffer_1w6">iterator</A> pos,
|
||||
InputIterator first, InputIterator last);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1775,7 +1775,7 @@ Swap the contents of two circular buffers. </td></tr></table>
|
||||
<a name="namespaceboost_1a9"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator!=(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1795,7 +1795,7 @@ Test two circular buffers for non-equality. </td></tr></table>
|
||||
<a name="namespaceboost_1a8"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator<(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1815,7 +1815,7 @@ Lexicographical comparison. </td></tr></table>
|
||||
<a name="namespaceboost_1a11"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator<=(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1835,7 +1835,7 @@ Lexicographical comparison. </td></tr></table>
|
||||
<a name="namespaceboost_1a7"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator==(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1855,7 +1855,7 @@ Test two circular buffers for equality. </td></tr></table>
|
||||
<a name="namespaceboost_1a10"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator>(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1875,7 +1875,7 @@ Lexicographical comparison. </td></tr></table>
|
||||
<a name="namespaceboost_1a12"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
bool operator>=(const circular_buffer<T,Alloc>& lhs, const circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1895,7 +1895,7 @@ Lexicographical comparison. </td></tr></table>
|
||||
<a name="namespaceboost_1a13"></a>
|
||||
<code>
|
||||
<b>
|
||||
template <class T, class Alloc><br>
|
||||
template <class T, class Alloc><br>
|
||||
void swap(circular_buffer<T,Alloc>& lhs, circular_buffer<T,Alloc>& rhs);</b>
|
||||
</code>
|
||||
<br>
|
||||
@@ -1916,145 +1916,145 @@ Swap the contents of two circular buffers. </td></tr></table>
|
||||
<a name="semantics">Semantics</a>
|
||||
</h2>
|
||||
<p>The behaviour of insertion for <code>circular_buffer</code> is as follows:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
The capacity of a <code>circular_buffer</code> remains fixed unless adjusted
|
||||
via <code>set_capacity</code> or <code>resize</code>.
|
||||
|
||||
The capacity of a <code>circular_buffer</code> remains fixed unless adjusted
|
||||
via <code>set_capacity</code> or <code>resize</code>.
|
||||
|
||||
<li>
|
||||
<code>insert</code> will
|
||||
overwrite front elements as necessary.
|
||||
|
||||
<code>insert</code> will
|
||||
overwrite front elements as necessary.
|
||||
|
||||
<li>
|
||||
<code>rinsert</code> will overwrite back elements as necessary.
|
||||
</li>
|
||||
</ul>
|
||||
<code>rinsert</code> will overwrite back elements as necessary.
|
||||
</li>
|
||||
</ul>
|
||||
<p>The behaviour of resizing a <code>circular_buffer</code> is as follows:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
The capacity will be adjusted to accommodate a <code>resize</code>. (The
|
||||
capacity can be only increased, not decreased.)
|
||||
</li>
|
||||
</ul>
|
||||
The capacity will be adjusted to accommodate a <code>resize</code>. (The
|
||||
capacity can be only increased, not decreased.)
|
||||
</li>
|
||||
</ul>
|
||||
<p>The behaviour of assigning to a <code>circular_buffer</code> is as follows:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
The capacity will be adjusted to accommodate an <code>assign</code>. (The
|
||||
capacity can be only increased, not decreased.)
|
||||
</li>
|
||||
</ul>
|
||||
<p><a name="invalidation"></a>The rules for iterator (and result of <code>data()</code>)
|
||||
invalidation for <code>circular_buffer</code> are as follows:
|
||||
</p>
|
||||
The capacity will be adjusted to accommodate an <code>assign</code>. (The
|
||||
capacity can be only increased, not decreased.)
|
||||
</li>
|
||||
</ul>
|
||||
<p><a name="invalidation"></a>The rules for iterator (and result of <code>data()</code>)
|
||||
invalidation for <code>circular_buffer</code> are as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>insert</code> at the end of the <code>circular_buffer</code> (including <code>
|
||||
push_back</code>) does not invalidate any iterator except
|
||||
the case the iterator points to the overwritten element.
|
||||
|
||||
<code>insert</code> at the end of the <code>circular_buffer</code> (including <code>
|
||||
push_back</code>) does not invalidate any iterator except
|
||||
the case the iterator points to the overwritten element.
|
||||
|
||||
<li>
|
||||
<code>rinsert</code> at the beginning of the <code>circular_buffer</code> (including
|
||||
<code>push_front</code>) does not invalidate any iterator
|
||||
except the case the iterator points to the overwritten element.
|
||||
|
||||
<code>rinsert</code> at the beginning of the <code>circular_buffer</code> (including
|
||||
<code>push_front</code>) does not invalidate any iterator
|
||||
except the case the iterator points to the overwritten element.
|
||||
|
||||
<li>
|
||||
<code>insert</code> in the middle of the <code>circular_buffer</code> invalidates
|
||||
iterators pointing to the elements at the insertion point and behind the
|
||||
insertion point. It also invalidates iterators pointing to the overwritten
|
||||
element(s).
|
||||
|
||||
<code>insert</code> in the middle of the <code>circular_buffer</code> invalidates
|
||||
iterators pointing to the elements at the insertion point and behind the
|
||||
insertion point. It also invalidates iterators pointing to the overwritten
|
||||
element(s).
|
||||
|
||||
<li>
|
||||
<code>rinsert</code> in the middle of the <code>circular_buffer</code> invalidates
|
||||
iterators pointing to the elements before the insertion point and iterators
|
||||
pointing to the overwritten element(s).
|
||||
|
||||
<code>rinsert</code> in the middle of the <code>circular_buffer</code> invalidates
|
||||
iterators pointing to the elements before the insertion point and iterators
|
||||
pointing to the overwritten element(s).
|
||||
|
||||
<li>
|
||||
<code>erase</code> at the end of the <code>circular_buffer</code> (including <code>pop_back</code>) invalidates only iterators pointing to
|
||||
the erased element(s).
|
||||
|
||||
<code>erase</code> at the end of the <code>circular_buffer</code> (including <code>pop_back</code>) invalidates only iterators pointing to
|
||||
the erased element(s).
|
||||
|
||||
<li>
|
||||
<code>pop_front</code>
|
||||
invalidates only iterators pointing to the erased element.
|
||||
|
||||
<code>pop_front</code>
|
||||
invalidates only iterators pointing to the erased element.
|
||||
|
||||
<li>
|
||||
<code>erase</code> at the beginning or in the middle of the <code>circular_buffer</code> invalidates iterators pointing to
|
||||
the erased element(s) and iterators pointing to the elements behind the erase
|
||||
point.
|
||||
|
||||
<code>erase</code> at the beginning or in the middle of the <code>circular_buffer</code> invalidates iterators pointing to
|
||||
the erased element(s) and iterators pointing to the elements behind the erase
|
||||
point.
|
||||
|
||||
<li>
|
||||
<code>data</code>, <code>set_capacity</code>, <code>resize</code>, <code>operator=</code>,
|
||||
<code>assign</code>, <code>swap</code> and <code>clear</code> invalidate all
|
||||
iterators pointing to the <code>circular_buffer</code>.
|
||||
</li>
|
||||
</ul>
|
||||
<p>In addition to the preceding rules the iterators get also invalidated due to
|
||||
overwritting (e.g. iterator pointing to the front-most element gets invalidated
|
||||
when inserting into the full <code>circular_buffer</code>). They get
|
||||
invalidated in that sense they do not point to the same element as before but
|
||||
they do still point to the same <b>valid</b> place in the memory. If you want
|
||||
to rely on this feature you have to turn of the <A href="#debug">Debug Support</A>
|
||||
otherwise an assertion will report an error if such invalidated iterator is used.</p>
|
||||
<code>data</code>, <code>set_capacity</code>, <code>resize</code>, <code>operator=</code>,
|
||||
<code>assign</code>, <code>swap</code> and <code>clear</code> invalidate all
|
||||
iterators pointing to the <code>circular_buffer</code>.
|
||||
</li>
|
||||
</ul>
|
||||
<p>In addition to the preceding rules the iterators get also invalidated due to
|
||||
overwritting (e.g. iterator pointing to the front-most element gets invalidated
|
||||
when inserting into the full <code>circular_buffer</code>). They get
|
||||
invalidated in that sense they do not point to the same element as before but
|
||||
they do still point to the same <b>valid</b> place in the memory. If you want
|
||||
to rely on this feature you have to turn of the <A href="#debug">Debug Support</A>
|
||||
otherwise an assertion will report an error if such invalidated iterator is used.</p>
|
||||
<h2>
|
||||
<a name="caveats">Caveats</a>
|
||||
</h2>
|
||||
<p>The <code>circular_buffer</code> should not be used for storing pointers to
|
||||
dynamically allocated objects. When a <code>circular_buffer</code> becomes
|
||||
full, further insertion will overwrite the stored pointers - resulting in a <b>memory
|
||||
leak</b>. One recommend alternative is the use of smart pointers <A href="#1">[1]</A>.
|
||||
(Any container of <code>std::auto_ptr</code> is considered particularly
|
||||
hazardous. <A href="#2">[2]</A>)
|
||||
</p>
|
||||
<p>Elements inserted near the front of a full <code>circular_buffer</code> can be
|
||||
lost. According to the <A href="#semantics">semantics</A> of <code>insert</code>,
|
||||
insertion overwrites front-most items as necessary - possibly including
|
||||
elements currently being <b>inserted at the front</b> of the buffer.
|
||||
Conversely, <code>push_front</code> to a full <code>circular_buffer</code> is
|
||||
guaranteed to overwrite the back-most element.
|
||||
</p>
|
||||
<p>Elements inserted near the back of a full <code>circular_buffer</code> can be
|
||||
lost. According to the <A href="#semantics">semantics</A> of <code>rinsert</code>,
|
||||
insertion overwrites front-most items as necessary - possibly including
|
||||
elements currently being <b>inserted at the back</b> of the buffer. Conversely, <code>
|
||||
push_back</code> to a full <code>circular_buffer</code> is guaranteed to
|
||||
overwrite the front-most element.
|
||||
</p>
|
||||
<p>While internals of a <code>circular_buffer</code> are circular, iterators are <b>not</b>.
|
||||
Iterators of a <code>circular_buffer</code> are only valid for the range <code>[begin(),
|
||||
end()]</code>. E.g. iterators <code>(begin() - 1)</code> and <code>(end() + 1)</code>
|
||||
are invalid.
|
||||
</p>
|
||||
<p>The <code>circular_buffer</code> should not be used for storing pointers to
|
||||
dynamically allocated objects. When a <code>circular_buffer</code> becomes
|
||||
full, further insertion will overwrite the stored pointers - resulting in a <b>memory
|
||||
leak</b>. One recommend alternative is the use of smart pointers <A href="#1">[1]</A>.
|
||||
(Any container of <code>std::auto_ptr</code> is considered particularly
|
||||
hazardous. <A href="#2">[2]</A>)
|
||||
</p>
|
||||
<p>Elements inserted near the front of a full <code>circular_buffer</code> can be
|
||||
lost. According to the <A href="#semantics">semantics</A> of <code>insert</code>,
|
||||
insertion overwrites front-most items as necessary - possibly including
|
||||
elements currently being <b>inserted at the front</b> of the buffer.
|
||||
Conversely, <code>push_front</code> to a full <code>circular_buffer</code> is
|
||||
guaranteed to overwrite the back-most element.
|
||||
</p>
|
||||
<p>Elements inserted near the back of a full <code>circular_buffer</code> can be
|
||||
lost. According to the <A href="#semantics">semantics</A> of <code>rinsert</code>,
|
||||
insertion overwrites front-most items as necessary - possibly including
|
||||
elements currently being <b>inserted at the back</b> of the buffer. Conversely, <code>
|
||||
push_back</code> to a full <code>circular_buffer</code> is guaranteed to
|
||||
overwrite the front-most element.
|
||||
</p>
|
||||
<p>While internals of a <code>circular_buffer</code> are circular, iterators are <b>not</b>.
|
||||
Iterators of a <code>circular_buffer</code> are only valid for the range <code>[begin(),
|
||||
end()]</code>. E.g. iterators <code>(begin() - 1)</code> and <code>(end() + 1)</code>
|
||||
are invalid.
|
||||
</p>
|
||||
<h2>
|
||||
<a name="debug">Debug Support</a>
|
||||
</h2>
|
||||
<p>In order to help a programmer to avoid and find common bugs, the <code>circular_buffer</code>
|
||||
contains a kind of debug support.</p>
|
||||
contains a kind of debug support.</p>
|
||||
<p>
|
||||
The <code>circular_buffer</code> maintains a list of valid iterators. As soon
|
||||
as any element gets destroyed all iterators pointing to this element are
|
||||
removed from this list and explicitly invalidated (an invalidation flag is
|
||||
set). The debug support also consists of many assertions (<a href="http://boost.org/libs/utility/assert.html"><code>BOOST_ASSERT</code></a>
|
||||
macros) which ensure the <code>circular_buffer</code> and its iterators are
|
||||
used in the correct manner at runtime. In case an invalid iterator is used the
|
||||
assertion will report an error. The connection of explicit iterator
|
||||
invalidation and assertions makes a very robust debug technique which catches
|
||||
most of the errors.</p>
|
||||
<p>Moreover, the uninitialized memory allocated by <code>circular_buffer</code> is
|
||||
filled with the value <code>0xcc</code> in the debug mode. This can help the
|
||||
programmer when debugging the code to recognize the initialized memory from the
|
||||
uninitialized. For details refer the <A href="../../../boost/circular_buffer/base.hpp">
|
||||
source code</A>.
|
||||
</p>
|
||||
The <code>circular_buffer</code> maintains a list of valid iterators. As soon
|
||||
as any element gets destroyed all iterators pointing to this element are
|
||||
removed from this list and explicitly invalidated (an invalidation flag is
|
||||
set). The debug support also consists of many assertions (<a href="http://boost.org/libs/utility/assert.html"><code>BOOST_ASSERT</code></a>
|
||||
macros) which ensure the <code>circular_buffer</code> and its iterators are
|
||||
used in the correct manner at runtime. In case an invalid iterator is used the
|
||||
assertion will report an error. The connection of explicit iterator
|
||||
invalidation and assertions makes a very robust debug technique which catches
|
||||
most of the errors.</p>
|
||||
<p>Moreover, the uninitialized memory allocated by <code>circular_buffer</code> is
|
||||
filled with the value <code>0xcc</code> in the debug mode. This can help the
|
||||
programmer when debugging the code to recognize the initialized memory from the
|
||||
uninitialized. For details refer the <A href="../../../boost/circular_buffer/base.hpp">
|
||||
source code</A>.
|
||||
</p>
|
||||
<p>The debug support is enabled only in the debug mode (when the <code>NDEBUG</code>
|
||||
is not defined). It can also be explicitly disabled by defining <code>BOOST_DISABLE_CB_DEBUG</code>
|
||||
macro.</p>
|
||||
is not defined). It can also be explicitly disabled by defining <code>BOOST_DISABLE_CB_DEBUG</code>
|
||||
macro.</p>
|
||||
<h2>
|
||||
<a name="example">Example</a>
|
||||
</h2>
|
||||
<p>The following example includes various usage of the <code>circular_buffer</code>.
|
||||
</p>
|
||||
</p>
|
||||
<pre> #include <boost/circular_buffer.hpp>
|
||||
#include <numeric>
|
||||
#include <assert.h>
|
||||
@@ -2062,7 +2062,7 @@ Swap the contents of two circular buffers. </td></tr></table>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// create a circular buffer of capacity 3
|
||||
boost::circular_buffer<int> cb(3);
|
||||
boost::circular_buffer<int> cb(3);
|
||||
|
||||
// insert some elements into the circular buffer
|
||||
cb.push_back(1);
|
||||
@@ -2090,35 +2090,35 @@ Swap the contents of two circular buffers. </td></tr></table>
|
||||
assert(cb.full());
|
||||
assert(cb.size() == 3);
|
||||
assert(cb.capacity() == 3);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre>
|
||||
<p>The <code>circular_buffer</code> has a capacity of three <code>int</code>.
|
||||
Therefore, the size of the buffer will not exceed three. The <code><a href="http://www.sgi.com/tech/stl/accumulate.html">
|
||||
accumulate</a></code> algorithm evaluates the sum of the stored
|
||||
elements. The semantics of the <code>circular_buffer</code> can be inferred from
|
||||
the assertions.
|
||||
</p>
|
||||
<p>The <code>circular_buffer</code> has a capacity of three <code>int</code>.
|
||||
Therefore, the size of the buffer will not exceed three. The <code><a href="http://www.sgi.com/tech/stl/accumulate.html">
|
||||
accumulate</a></code> algorithm evaluates the sum of the stored
|
||||
elements. The semantics of the <code>circular_buffer</code> can be inferred from
|
||||
the assertions.
|
||||
</p>
|
||||
<h2>
|
||||
<a name="notes">Notes</a>
|
||||
</h2>
|
||||
<p><a name="1">[1]</a> A good implementation of smart pointers is included in <a href="http://boost.org/libs/smart_ptr">
|
||||
Boost</a>.
|
||||
</p>
|
||||
<p><a name="2">[2]</a> Never create a circular buffer of <code>std::auto_ptr</code>.
|
||||
Refer to <a href="http://www.aristeia.com">Scott Meyers</a>' excellent book <em>Effective
|
||||
STL</em> for a detailed discussion. (Meyers S., <i>Effective STL: 50 Specific
|
||||
Ways to Improve Your Use of the Standard Template Library</i>.
|
||||
Addison-Wesley, 2001.)
|
||||
</p>
|
||||
Boost</a>.
|
||||
</p>
|
||||
<p><a name="2">[2]</a> Never create a circular buffer of <code>std::auto_ptr</code>.
|
||||
Refer to <a href="http://www.aristeia.com">Scott Meyers</a>' excellent book <em>Effective
|
||||
STL</em> for a detailed discussion. (Meyers S., <i>Effective STL: 50 Specific
|
||||
Ways to Improve Your Use of the Standard Template Library</i>.
|
||||
Addison-Wesley, 2001.)
|
||||
</p>
|
||||
<h2>
|
||||
<a name="see">See also</a>
|
||||
</h2>
|
||||
<p><code><A href="circular_buffer_space_optimized.html">boost::circular_buffer_space_optimized</A>,
|
||||
<a href="http://www.sgi.com/tech/stl/Vector.html">std::vector</a>, <a href="http://www.sgi.com/tech/stl/List.html">
|
||||
std::list</a>, <a href="http://www.sgi.com/tech/stl/Deque.html">std::deque</a></code>
|
||||
</p>
|
||||
<a href="http://www.sgi.com/tech/stl/Vector.html">std::vector</a>, <a href="http://www.sgi.com/tech/stl/List.html">
|
||||
std::list</a>, <a href="http://www.sgi.com/tech/stl/Deque.html">std::deque</a></code>
|
||||
</p>
|
||||
<h2><A name="ideas">Ideas for Future Improvements</A>
|
||||
</h2>
|
||||
<p>The formal review revealed that the library is lack of adaptors which would provide additional
|
||||
@@ -2130,18 +2130,18 @@ e.g. for invoking some method on the element being overwritten or for throwing a
|
||||
exception.
|
||||
</p>
|
||||
<h2><a name="ack">Acknowledgments</a></h2>
|
||||
<p>The <code>circular_buffer</code> has a short history. Its first version was a <code>std::deque</code> adaptor. This container was not very
|
||||
effective because of many reallocations when inserting/removing an element.
|
||||
Thomas Wenish did a review of this version and motivated me to create a circular
|
||||
<p>The <code>circular_buffer</code> has a short history. Its first version was a <code>std::deque</code> adaptor. This container was not very
|
||||
effective because of many reallocations when inserting/removing an element.
|
||||
Thomas Wenish did a review of this version and motivated me to create a circular
|
||||
buffer which allocates memory at once when created.</p>
|
||||
<p>The second version adapted <code>std::vector</code> but it has been abandoned
|
||||
soon because of limited control over iterator invalidation.</p>
|
||||
<p>The current version is
|
||||
a full-fledged STL compliant container. Pavel Vozenilek did a thorough review of this version
|
||||
and came with many good ideas and improvements. Also, I would like to
|
||||
thank Howard Hinnant, Nigel Stewart and everyone who participated at the formal review for valuable
|
||||
comments and ideas.
|
||||
</p>
|
||||
<p>The second version adapted <code>std::vector</code> but it has been abandoned
|
||||
soon because of limited control over iterator invalidation.</p>
|
||||
<p>The current version is
|
||||
a full-fledged STL compliant container. Pavel Vozenilek did a thorough review of this version
|
||||
and came with many good ideas and improvements. Also, I would like to
|
||||
thank Howard Hinnant, Nigel Stewart and everyone who participated at the formal review for valuable
|
||||
comments and ideas.
|
||||
</p>
|
||||
<hr align="left" size="1">
|
||||
<table id="footer" border="0" width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -5,9 +5,9 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
|
||||
<xsl:import href="doxygen2html.xslt"/>
|
||||
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/xml"/>
|
||||
|
||||
<xsl:variable name="link-prefix" select="''"/>
|
||||
@@ -16,17 +16,17 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
<xsl:template name="reference">
|
||||
<xsl:value-of select="concat('#', @refid)"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="template-parameters">
|
||||
<xsl:apply-templates select="templateparamlist/param" mode="synopsis"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="public-types">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-type']/memberdef" mode="synopsis">
|
||||
<xsl:sort select="name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="member-functions">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type != '']" mode="synopsis">
|
||||
<xsl:sort select="name"/>
|
||||
@@ -39,29 +39,29 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
<xsl:with-param name="indent" select="''"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="template-parameters-details">
|
||||
<xsl:apply-templates select="detaileddescription//parameterlist[@kind='param']/parameteritem" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="public-types-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-type']/memberdef" mode="description">
|
||||
<xsl:sort select="name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="constructors-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type = '']" mode="description">
|
||||
<xsl:sort select="name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="member-functions-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type != '']" mode="description">
|
||||
<xsl:sort select="name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="standalone-functions-details">
|
||||
<xsl:apply-templates select="$standalone-functions/memberdef[contains(argsstring, 'circular_buffer<')]" mode="description">
|
||||
<xsl:sort select="name"/>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
|
||||
<title>Space Optimized Circular Buffer Container Adaptor</title>
|
||||
</head>
|
||||
<body bgcolor="#ffffff">
|
||||
@@ -10,47 +10,47 @@
|
||||
<table id="title" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h1>circular_buffer_space_optimized<T, Alloc></h1>
|
||||
</td>
|
||||
<td><a href="http://boost.org"><img height="86" src="../../../c++boost.gif" width="277" border="0" alt="Boost"></a></td>
|
||||
</tr>
|
||||
<h1>circular_buffer_space_optimized<T, Alloc></h1>
|
||||
</td>
|
||||
<td><a href="http://boost.org"><img height="86" src="../../../c++boost.gif" width="277" border="0" alt="Boost"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Contents</h2>
|
||||
<a href="#description">Description</a><br>
|
||||
<a href="#synopsis">Synopsis</a><br>
|
||||
<a href="#rationale">Rationale</a><br>
|
||||
<a href="#header">Header files</a><br>
|
||||
<a href="#model">Modeled concepts</a><br>
|
||||
<a href="#members">Template Parameters, Members and Standalone
|
||||
Functions</a><br>
|
||||
<a href="#semantics">Semantics</a><br>
|
||||
<a href="#see">See also</a><br>
|
||||
<a href="#ack">Acknowledgments</a>
|
||||
<a href="#synopsis">Synopsis</a><br>
|
||||
<a href="#rationale">Rationale</a><br>
|
||||
<a href="#header">Header files</a><br>
|
||||
<a href="#model">Modeled concepts</a><br>
|
||||
<a href="#members">Template Parameters, Members and Standalone
|
||||
Functions</a><br>
|
||||
<a href="#semantics">Semantics</a><br>
|
||||
<a href="#see">See also</a><br>
|
||||
<a href="#ack">Acknowledgments</a>
|
||||
<h2>
|
||||
<a name="description">Description</a>
|
||||
</h2>
|
||||
<p>The <code>circular_buffer_space_optimized</code> container is an adaptor of the <code>
|
||||
<a href="circular_buffer.html">circular_buffer</a></code>. The
|
||||
functionality of the <code>circular_buffer_space_optimized</code> is similar to
|
||||
the base <code>circular_buffer</code> except it does not allocate memory at
|
||||
once when created rather it allocates memory as needed. (The predictive memory
|
||||
allocation is similar to typical <code>std::vector</code> implementation.)
|
||||
Moreover the memory is automatically freed as the size of the container
|
||||
decreases.
|
||||
</p>
|
||||
<a href="circular_buffer.html">circular_buffer</a></code>. The
|
||||
functionality of the <code>circular_buffer_space_optimized</code> is similar to
|
||||
the base <code>circular_buffer</code> except it does not allocate memory at
|
||||
once when created rather it allocates memory as needed. (The predictive memory
|
||||
allocation is similar to typical <code>std::vector</code> implementation.)
|
||||
Moreover the memory is automatically freed as the size of the container
|
||||
decreases.
|
||||
</p>
|
||||
<table id="figure" border="0">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><img height="350" src="circular_buffer_space_optimized.png" width="700" alt="Space Optimized Circular Buffer"></td>
|
||||
</tr>
|
||||
<td><img height="350" src="circular_buffer_space_optimized.png" width="700" alt="Space Optimized Circular Buffer"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><b>Figure:</b></td>
|
||||
<td valign="top">The memory allocation process of the space optimized circular
|
||||
buffer. The <code>min_capacity</code> represents the minimal guaranteed amount
|
||||
of allocated memory. The allocated memory will never drop under this value. By
|
||||
default the <code>min_capacity</code> is set to 0.
|
||||
</td>
|
||||
</tr>
|
||||
<td valign="top">The memory allocation process of the space optimized circular
|
||||
buffer. The <code>min_capacity</code> represents the minimal guaranteed amount
|
||||
of allocated memory. The allocated memory will never drop under this value. By
|
||||
default the <code>min_capacity</code> is set to 0.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<h2>
|
||||
@@ -81,13 +81,13 @@ public:
|
||||
typedef typename Alloc::value_type <a href="circular_buffer.html#classboost_1_1circular__buffer_1w13">value_type</a>;
|
||||
|
||||
template <class InputIterator>
|
||||
<a href="#classboost_1_1circular__buffer__space__optimized_1a3">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
size_type min_capacity, InputIterator first,
|
||||
<a href="#classboost_1_1circular__buffer__space__optimized_1a3">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
size_type min_capacity, InputIterator first,
|
||||
InputIterator last, const allocator_type& alloc = allocator_type());
|
||||
<a href="#classboost_1_1circular__buffer__space__optimized_1a4">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
size_type min_capacity, value_type item,
|
||||
<a href="#classboost_1_1circular__buffer__space__optimized_1a4">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
size_type min_capacity, value_type item,
|
||||
const allocator_type& alloc = allocator_type());
|
||||
explicit <a href="#classboost_1_1circular__buffer__space__optimized_1a5">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
explicit <a href="#classboost_1_1circular__buffer__space__optimized_1a5">circular_buffer_space_optimized</a>(size_type capacity,
|
||||
size_type min_capacity = 0, const allocator_type& alloc = allocator_type());
|
||||
|
||||
template <class InputIterator>
|
||||
@@ -145,25 +145,25 @@ public:
|
||||
};
|
||||
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a9">operator!=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a9">operator!=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a8">operator<</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a8">operator<</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a11">operator<=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a11">operator<=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a7">operator==</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a7">operator==</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a10">operator></a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a10">operator></a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a12">operator>=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
bool <a href="circular_buffer.html#namespaceboost_1a12">operator>=</a>(const circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
const circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
template <class T, class Alloc>
|
||||
void <a href="circular_buffer.html#namespaceboost_1a13">swap</a>(circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
void <a href="circular_buffer.html#namespaceboost_1a13">swap</a>(circular_buffer_space_optimized<T,Alloc>& lhs,
|
||||
circular_buffer_space_optimized<T,Alloc>& rhs);
|
||||
|
||||
} // namespace boost
|
||||
@@ -175,43 +175,43 @@ template
|
||||
<h2>
|
||||
<a name="rationale">Rationale</a>
|
||||
</h2>
|
||||
<p>The auto-resizing mode of the space optimized circular buffer can be useful in
|
||||
situations when the container can possibly store large number of elements but
|
||||
most of its lifetime the container stores just few of them. The usage of the <code>circular_buffer_space_optimized</code>
|
||||
will result in decreased memory consumption and can improve the CPU cache
|
||||
effectiveness.
|
||||
</p>
|
||||
<p>The auto-resizing mode of the space optimized circular buffer can be useful in
|
||||
situations when the container can possibly store large number of elements but
|
||||
most of its lifetime the container stores just few of them. The usage of the <code>circular_buffer_space_optimized</code>
|
||||
will result in decreased memory consumption and can improve the CPU cache
|
||||
effectiveness.
|
||||
</p>
|
||||
<h2>
|
||||
<a name="header">Header files</a>
|
||||
</h2>
|
||||
<p>
|
||||
The <code>circular_buffer_space_optimized</code> is defined in the file
|
||||
The <code>circular_buffer_space_optimized</code> is defined in the file
|
||||
<code><a href="../../../boost/circular_buffer.hpp">boost/circular_buffer.hpp</a></code>.
|
||||
There is also a forward declaration for the <code>circular_buffer_space_optimized</code> in the header file
|
||||
<code><a href="../../../boost/circular_buffer_fwd.hpp">boost/circular_buffer_fwd.hpp</a></code>.
|
||||
</p>
|
||||
</p>
|
||||
<h2>
|
||||
<a name="model">Modeled concepts</a>
|
||||
</h2>
|
||||
<p><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">Random Access
|
||||
Container</a>, <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
Front Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
Back Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
Assignable</a> (SGI specific), <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">
|
||||
Equality Comparable</a>, <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">
|
||||
LessThan Comparable</a> (SGI specific)
|
||||
</p>
|
||||
<p><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">Random Access
|
||||
Container</a>, <a href="http://www.sgi.com/tech/stl/FrontInsertionSequence.html">
|
||||
Front Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/BackInsertionSequence.html">
|
||||
Back Insertion Sequence</a>, <a href="http://www.sgi.com/tech/stl/Assignable.html">
|
||||
Assignable</a> (SGI specific), <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">
|
||||
Equality Comparable</a>, <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">
|
||||
LessThan Comparable</a> (SGI specific)
|
||||
</p>
|
||||
<h2>
|
||||
<a name="members">Template Parameters, Members and Friend Functions</a>
|
||||
</h2>
|
||||
<p>Template parameters, members and friend functions of the <code>circular_buffer_space_optimized</code>
|
||||
are almost the same as for the base <code>circular_buffer</code>. Refer the <code>circular_buffer</code>
|
||||
<a href="circular_buffer.html#parameters">documentation</a> and also its <a href="srcdoc/index.html">
|
||||
source code documentation</a> for a detailed description.
|
||||
</p>
|
||||
<p>The specific methods of the <code>circular_buffer_space_optimized</code> are
|
||||
listed below.
|
||||
</p>
|
||||
are almost the same as for the base <code>circular_buffer</code>. Refer the <code>circular_buffer</code>
|
||||
<a href="circular_buffer.html#parameters">documentation</a> and also its <a href="srcdoc/index.html">
|
||||
source code documentation</a> for a detailed description.
|
||||
</p>
|
||||
<p>The specific methods of the <code>circular_buffer_space_optimized</code> are
|
||||
listed below.
|
||||
</p>
|
||||
<h2>
|
||||
<a name="constructors">Constructors</a>
|
||||
</h2>
|
||||
@@ -718,60 +718,60 @@ See the <a href="#classboost_1_1circular__buffer">circular_buffer</a> source doc
|
||||
<a name="semantics">Semantics</a>
|
||||
</h2>
|
||||
<p>The behaviour of memory auto-resizing is as follows:
|
||||
</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Minimal capacity is allocated when an empty <code>circular_buffer_space_optimized</code>
|
||||
is created.
|
||||
</li>
|
||||
Minimal capacity is allocated when an empty <code>circular_buffer_space_optimized</code>
|
||||
is created.
|
||||
</li>
|
||||
<li>
|
||||
When a non-empty <code>circular_buffer_space_optimized</code>
|
||||
container is created the allocated memory reflects the size of the container.
|
||||
</li>
|
||||
When a non-empty <code>circular_buffer_space_optimized</code>
|
||||
container is created the allocated memory reflects the size of the container.
|
||||
</li>
|
||||
<li>
|
||||
<code>push_back</code>, <code>push_front</code>, <code>insert</code> and <code>rinsert</code>
|
||||
will predictively increase the allocated memory if necessary. (The predictive
|
||||
memory allocation is similar to <code>std::vector</code>.)
|
||||
</li>
|
||||
<code>push_back</code>, <code>push_front</code>, <code>insert</code> and <code>rinsert</code>
|
||||
will predictively increase the allocated memory if necessary. (The predictive
|
||||
memory allocation is similar to <code>std::vector</code>.)
|
||||
</li>
|
||||
<li>
|
||||
<code>set_capacity</code>, <code>resize</code>, <code>assign</code>, <code>insert</code>
|
||||
(range or n items), <code>rinsert</code> (range or n items), <code>erase</code>
|
||||
(range) and <code>clear</code>
|
||||
will accommodate the allocated memory as necessary.
|
||||
</li>
|
||||
<code>set_capacity</code>, <code>resize</code>, <code>assign</code>, <code>insert</code>
|
||||
(range or n items), <code>rinsert</code> (range or n items), <code>erase</code>
|
||||
(range) and <code>clear</code>
|
||||
will accommodate the allocated memory as necessary.
|
||||
</li>
|
||||
<li>
|
||||
<code>pop_back</code>, <code>pop_front</code>, <code>erase</code> and <code>clear</code>
|
||||
will predictively decrease the allocated memory.
|
||||
</li>
|
||||
</ul>
|
||||
<p>The semantics of the <code>circular_buffer_space_optimized</code> then follows
|
||||
the <a href="circular_buffer.html#semantics">semantics</a> of the base <code>circular_buffer</code>
|
||||
except the invalidation rules.
|
||||
</p>
|
||||
<code>pop_back</code>, <code>pop_front</code>, <code>erase</code> and <code>clear</code>
|
||||
will predictively decrease the allocated memory.
|
||||
</li>
|
||||
</ul>
|
||||
<p>The semantics of the <code>circular_buffer_space_optimized</code> then follows
|
||||
the <a href="circular_buffer.html#semantics">semantics</a> of the base <code>circular_buffer</code>
|
||||
except the invalidation rules.
|
||||
</p>
|
||||
<p><a name="invalidation"></a>The rule for iterator invalidation for <code>circular_buffer_space_optimized</code>
|
||||
is as follows:
|
||||
</p>
|
||||
is as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>data</code>, <code>set_capacity</code>, <code>resize</code>, <code>operator=</code>,
|
||||
<code>assign</code>, <code>swap</code>, <code>push_back</code>, <code>push_front</code>,
|
||||
<code>pop_back</code>, <code>pop_front</code>, <code>insert</code>, <code>rinsert</code>,
|
||||
<code>erase</code> and <code>clear</code> invalidate all iterators pointing to
|
||||
the <code>circular_buffer_space_optimized</code>.
|
||||
</li>
|
||||
</ul>
|
||||
<code>data</code>, <code>set_capacity</code>, <code>resize</code>, <code>operator=</code>,
|
||||
<code>assign</code>, <code>swap</code>, <code>push_back</code>, <code>push_front</code>,
|
||||
<code>pop_back</code>, <code>pop_front</code>, <code>insert</code>, <code>rinsert</code>,
|
||||
<code>erase</code> and <code>clear</code> invalidate all iterators pointing to
|
||||
the <code>circular_buffer_space_optimized</code>.
|
||||
</li>
|
||||
</ul>
|
||||
<h2>
|
||||
<a name="see">See also</a>
|
||||
</h2>
|
||||
<p><code><a href="circular_buffer.html">boost::circular_buffer</a>, <a href="http://www.sgi.com/tech/stl/Vector.html">
|
||||
std::vector</a></code>
|
||||
</p>
|
||||
std::vector</a></code>
|
||||
</p>
|
||||
<h2>
|
||||
<a name="ack">Acknowledgments</a>
|
||||
</h2>
|
||||
<p>The idea of the space optimized circular buffer has been introduced by Pavel
|
||||
Vozenilek.
|
||||
</p>
|
||||
<p>The idea of the space optimized circular buffer has been introduced by Pavel
|
||||
Vozenilek.
|
||||
</p>
|
||||
<hr align="left" size="1">
|
||||
<table id="footer" border="0" width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -9,19 +9,19 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
<xsl:import href="doxygen2html.xslt"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/xml"/>
|
||||
|
||||
|
||||
<xsl:variable name="override-mark" select="'!'"/>
|
||||
<xsl:variable name="link-prefix" select="'circular_buffer.html'"/>
|
||||
<xsl:variable name="circular_buffer-ref" select="//compound[name='boost::circular_buffer' and @kind='class']/@refid"/>
|
||||
<xsl:variable name="circular_buffer-file" select="concat($xmldir, '/', $circular_buffer-ref, '.xml')"/>
|
||||
<xsl:variable name="circular_buffer-reimplemented" select="document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']//reimplementedby"/>
|
||||
<xsl:variable name="standalone-functions" select="document(concat($xmldir, '/namespaceboost.xml'))/doxygen/compounddef/sectiondef[@kind='func']"/>
|
||||
|
||||
|
||||
<xsl:template name="reference">
|
||||
<xsl:variable name="refid" select="$circular_buffer-reimplemented[@refid=current()/@refid]/../@id"/>
|
||||
<xsl:value-of select="concat(substring(concat($link-prefix, '#', $refid), 1 div (string-length($refid) > 0)), substring(concat('#', @refid), 1 div (string-length($refid) = 0)))"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="template-parameters">
|
||||
<xsl:apply-templates select="templateparamlist/param" mode="synopsis">
|
||||
<xsl:with-param name="link-prefix" select="$link-prefix"/>
|
||||
@@ -45,7 +45,7 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="member-functions">
|
||||
<xsl:variable name="current" select="sectiondef[@kind='public-func']/memberdef[type != '']"/>
|
||||
<xsl:for-each select="$current | document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']/sectiondef[@kind='public-func']/memberdef[type != '']">
|
||||
@@ -100,7 +100,7 @@ Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
<xsl:variable name="briefdescription" select="normalize-space(briefdescription)"/>
|
||||
<xsl:if test="string-length($briefdescription) > 0 and (starts-with($briefdescription, $override-mark) or count(reimplements) = 0)">
|
||||
<xsl:apply-templates select="." mode="description"/>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:template match="/ | node() | @* | comment() | processing-instruction()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template match="/ | node() | @* | comment() | processing-instruction()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
]>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
|
||||
<xsl:param name="container"/>
|
||||
<xsl:param name="xmldir"/>
|
||||
<xsl:variable name="default-keyword">Default: </xsl:variable>
|
||||
@@ -14,7 +14,7 @@
|
||||
<xsl:variable name="container-ref" select="//compound[name=concat('boost::', $container) and @kind='class']/@refid"/>
|
||||
<xsl:variable name="class-file" select="concat($xmldir, '/', $container-ref, '.xml')"/>
|
||||
<xsl:variable name="class" select="document($class-file)/doxygen/compounddef[@id = $container-ref]"/>
|
||||
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:if test="doxygenindex/@version != $doxygen-version">
|
||||
<xsl:message>Warning: The source documentation was generated by the doxygen version <xsl:value-of select="doxygenindex/@version"/> which differs from the reference doxygen version (<xsl:value-of select="$doxygen-version"/>).</xsl:message>
|
||||
@@ -27,15 +27,15 @@
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="linebreak">
|
||||
<br />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="computeroutput">
|
||||
<code><xsl:apply-templates/></code>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="para">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
@@ -46,11 +46,11 @@
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="ulink">
|
||||
<a href="{@url}"><xsl:apply-templates/></a>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="parameteritem">
|
||||
<xsl:param name="desc" select="''"/>
|
||||
<tr>
|
||||
@@ -66,7 +66,7 @@
|
||||
</tr>
|
||||
<xsl:apply-templates select="following-sibling[1]"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="parameterlist[@kind='param']">
|
||||
<table id="table_param_desc_{generate-id(.)}">
|
||||
<xsl:apply-templates select="parameteritem[1]">
|
||||
@@ -74,7 +74,7 @@
|
||||
</xsl:apply-templates>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="parameterlist[@kind='exception']">
|
||||
<table id="table_exception_desc_{generate-id(.)}">
|
||||
<xsl:apply-templates select="parameteritem[1]">
|
||||
@@ -82,25 +82,25 @@
|
||||
</xsl:apply-templates>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="simplesect[@kind='return']">
|
||||
<table id="table_return_desc_{generate-id(.)}">
|
||||
<tr><td valign="top"><b>Returns:</b></td><td><xsl:apply-templates/></td></tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="simplesect[@kind='pre']">
|
||||
<table id="table_pre_desc_{generate-id(.)}">
|
||||
<tr><td valign="top"><b>Precondition:</b></td><td><xsl:apply-templates/></td></tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="simplesect[@kind='post']">
|
||||
<table id="table_post_desc_{generate-id(.)}">
|
||||
<tr><td valign="top"><b>Postcondition:</b></td><td><xsl:apply-templates/></td></tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="simplesect[@kind='note']">
|
||||
<table id="table_note_desc_{generate-id(.)}">
|
||||
<tr><td valign="top"><b>Note:</b></td><td><xsl:apply-templates/></td></tr>
|
||||
@@ -112,7 +112,7 @@
|
||||
<tr><td><xsl:apply-templates/></td></tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="detaileddescription/para">
|
||||
<xsl:if test="normalize-space(text()) != ''">
|
||||
<table id="table_detailed_desc_{generate-id(.)}">
|
||||
@@ -123,7 +123,7 @@
|
||||
</xsl:template>
|
||||
|
||||
<!-- Synopsis mode -->
|
||||
|
||||
|
||||
<xsl:template match="compounddef[@kind = 'class']" mode="synopsis">
|
||||
<div id="srcdoc_synopsis">
|
||||
<table id="table_synopsis" border="0" cellpadding="10">
|
||||
@@ -151,12 +151,12 @@ public:
|
||||
</table>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="param" mode="synopsis">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:value-of select="type"/> <a href="{$link-prefix}#templateparam_{declname}"><xsl:value-of select="declname"/></a><xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="memberdef[@kind='typedef']" mode="synopsis">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:if test="normalize-space(briefdescription) != ''"> typedef <xsl:value-of select="substring('typename ', 1 div (contains(type, '::') and not(contains(type, '>'))))"/>
|
||||
@@ -205,9 +205,9 @@ public:
|
||||
<xsl:if test="name(.) != 'ref' and position() != last()"> </xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Description mode -->
|
||||
|
||||
|
||||
<xsl:template match="compounddef[@kind = 'class']" mode="description">
|
||||
<div id="srcdoc_params">
|
||||
<table id="table_template_params" border="1">
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
</table>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="parameteritem" mode="description">
|
||||
<tr><td><a name="templateparam_{parameternamelist/parametername}"><code><xsl:value-of select="parameternamelist/parametername"/></code></a></td>
|
||||
<xsl:choose>
|
||||
@@ -251,14 +251,14 @@ public:
|
||||
</xsl:otherwise>
|
||||
</xsl:choose></tr>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="memberdef[@kind='typedef']" mode="description">
|
||||
<xsl:if test="normalize-space(briefdescription) != ''">
|
||||
<tr><td><a name="{@id}"><code><xsl:value-of select="name"/></code></a></td>
|
||||
<td><xsl:value-of select="briefdescription"/></td></tr>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="memberdef[@kind='function']" mode="description">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:variable name="too-long-args" select="string-length(argsstring) > 80"/>
|
||||
|
||||
@@ -4,9 +4,9 @@ Helper XSL transformation which converts HTML into XHTML.
|
||||
Author: Jan Gaspar (jano_gaspar[at]yahoo.com)
|
||||
-->
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
|
||||
<xsl:import href="copy.xslt"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/html"/>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -5,4 +5,26 @@ function rb {
|
||||
mv $1.temp $1
|
||||
}
|
||||
|
||||
rb 'test.txt'
|
||||
rb ../../../boost/circular_buffer.hpp
|
||||
rb ../../../boost/circular_buffer_fwd.hpp
|
||||
rb ../../../boost/circular_buffer/adaptor.hpp
|
||||
rb ../../../boost/circular_buffer/base.hpp
|
||||
rb ../../../boost/circular_buffer/debug.hpp
|
||||
rb ../../../boost/circular_buffer/details.hpp
|
||||
rb ../index.html
|
||||
rb Doxyfile
|
||||
rb circular_buffer.html
|
||||
rb circular_buffer.xslt
|
||||
rb circular_buffer_space_optimized.html
|
||||
rb circular_buffer_space_optimized.xslt
|
||||
rb copy.xslt
|
||||
rb doxygen2html.xslt
|
||||
rb html2xhtml.xslt
|
||||
rb update_srcdoc.bat
|
||||
rb update_srcdoc.sh
|
||||
rb update_srcdoc.xslt
|
||||
rb ../test/Jamfile
|
||||
rb ../test/adaptor_test.cpp
|
||||
rb ../test/base_test.cpp
|
||||
rb ../test/common.cpp
|
||||
rb ../test/test.hpp
|
||||
|
||||
@@ -6,19 +6,19 @@ if [ -f $DOCFILE ]; then
|
||||
|
||||
echo Starting Doxygen ...
|
||||
# doxygen
|
||||
|
||||
|
||||
echo Generating source XHTML documentation ...
|
||||
xsltproc --stringparam container $1 --stringparam xmldir srcdoc -o srcdoc/srcdoc.xhtml $1.xslt srcdoc/index.xml
|
||||
|
||||
|
||||
echo Converting original HTML documentation into XHTML ...
|
||||
xsltproc --html -o srcdoc/$1.xhtml html2xhtml.xslt $DOCFILE
|
||||
|
||||
|
||||
echo Creating HTML documentation with updated source documentation ...
|
||||
xsltproc --stringparam srcdoc srcdoc/srcdoc.xhtml -o $DOCFILE update_srcdoc.xslt srcdoc/$1.xhtml
|
||||
|
||||
|
||||
echo Removing temporary directory ...
|
||||
# rm -rf srcdoc
|
||||
|
||||
|
||||
echo Done.
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user