diff --git a/doc/Doxyfile b/doc/Doxyfile
deleted file mode 100644
index a57e929..0000000
--- a/doc/Doxyfile
+++ /dev/null
@@ -1,227 +0,0 @@
-# Doxygen configuration file.
-#
-# 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)
-#
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = "Circular Buffer"
-PROJECT_NUMBER = 3.7
-OUTPUT_DIRECTORY = srcdoc
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-USE_WINDOWS_ENCODING = NO
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = YES
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = NO
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = NO
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = YES
-EXTRACT_PRIVATE = YES
-EXTRACT_STATIC = YES
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = YES
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = NO
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = NO
-SHOW_DIRECTORIES = YES
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = ../../../boost/circular_buffer
-FILE_PATTERNS = *.hpp
-RECURSIVE = YES
-EXCLUDE = ../../../boost/circular_buffer/debug.hpp \
- ../../../boost/circular_buffer/details.hpp
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = NO
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION = YES
-VERBATIM_HEADERS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
-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_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = NO
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = YES
-XML_OUTPUT = .
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = NO
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# 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 =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = NO
-PERL_PATH =
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = NO
-HIDE_UNDOC_RELATIONS = NO
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = YES
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = NO
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 0
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
diff --git a/doc/HOWTO-srcdoc b/doc/HOWTO-srcdoc
deleted file mode 100644
index a846b48..0000000
--- a/doc/HOWTO-srcdoc
+++ /dev/null
@@ -1,52 +0,0 @@
-################################################################################
-# HOW-TO documentation about generating/updating source code documentation for #
-# the Circular Buffer library. #
-# #
-# 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 #
-# http://www.boost.org/LICENSE_1_0.txt) #
-################################################################################
-
-The source code documentation (i.e. documentation of functions, classes and
-their methods, etc.) is part of the source code. This makes it convenient for
-a developer when browsing source files or developing new (documented) code.
-The source code documentation is included in the larger, more detailed library
-documentation as well which makes it more convenient for the user of the
-library. In order to make it easier for the developer, the source code
-documentation included in the library documentation is generated from the source
-files. Which means the developer does not have to write the same source
-documentation twice.
-
-Prerequisites:
-
-1) Unix/Linux shell (with sed editor) available.
- (The script can be easily converted into Windows batch file if you do not
- have access to Unix/Linux shell.)
-2) Installed Doxygen http://www.doxygen.org.
- (Source documentation generation was tested with the Doxygen version
- 1.4.6.)
-3) Installed xsltproc http://xmlsoft.org/XSLT/xsltproc2.html.
-4) Installed HTML Tidy http://tidy.sourceforge.net. (Tested with version
- released on 1 September 2005.)
-
-
-Updating source code documentation:
-
-The source code documentation of the Circular Buffer library obeys the Doxygen
-syntax. The library documentation is written in HTML (files circular_buffer.html
-and space_optimized.html). The generation of the source code documentation is
-performed by executing the update_srcdoc.sh script which relies mainly on
-Doxygen and several XSL transformations.
-
-After editing the source code documentation in the source file(s), update the
-library documentation by executing:
-
-$>./update_srcdoc.sh circular_buffer
-
-for the circular_buffer or/and
-
-$>./update_srcdoc.sh circular_buffer_space_optimized
-
-for the circular_buffer_space_optimized.
diff --git a/doc/Tidy.conf b/doc/Tidy.conf
deleted file mode 100644
index 7e00237..0000000
--- a/doc/Tidy.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-# HTML Tidy configuration file.
-#
-# 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)
-#
-bare: yes
-char-encoding: latin1
-doctype: transitional
-indent: yes
-indent-attributes: no
-quiet: yes
-show-warnings: no
-tidy-mark: no
-wrap: 120
-write-back: yes
diff --git a/doc/circular_buffer.html b/doc/circular_buffer.html
deleted file mode 100644
index f12fb5a..0000000
--- a/doc/circular_buffer.html
+++ /dev/null
@@ -1,6788 +0,0 @@
-
-
-
- In general the term circular buffer refers to an area in memory which is used to store incoming data. When
- the buffer is filled, new data is written starting at the beginning of the buffer and overwriting the old. (Also
- see the Figure.)
-
-
- The circular_buffer is a STL compliant container. It is a kind of sequence similar to std::list or std::deque. It supports random access iterators, constant
- time insert and erase operations at the beginning or the end of the buffer and interoperability with
- std algorithms. The circular_buffer is especially designed to provide fixed capacity
- storage. When its capacity is exhausted, newly inserted elements will cause elements either at the beginning or
- end of the buffer (depending on what insert operation is used) to be overwritten.
-
-
- The circular_buffer only allocates memory when created, when the capacity is adjusted explicitly, or
- as necessary to accommodate resizing or assign operations. On the other hand, there is also a circular_buffer_space_optimized available. It is an adaptor of the
- circular_buffer which does not allocate memory at once when created, rather it allocates memory as
- needed.
-
- #include <boost/circular_buffer.hpp>
-
- int main(int /*argc*/, char* /*argv*/[]) {
-
- // Create a circular buffer with a capacity for 3 integers.
- boost::circular_buffer<int> cb(3);
-
- // Insert some elements into the buffer.
- cb.push_back(1);
- cb.push_back(2);
- cb.push_back(3);
-
- int a = cb[0]; // a == 1
- int b = cb[1]; // b == 2
- int c = cb[2]; // c == 3
-
- // 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.
-
- // The buffer now contains 3, 4 and 5.
-
- a = cb[0]; // a == 3
- b = cb[1]; // b == 4
- c = cb[2]; // c == 5
-
- // Elements can be popped from either the front or the back.
-
- cb.pop_back(); // 5 is removed.
- cb.pop_front(); // 3 is removed.
-
- int d = cb[0]; // d == 4
-
- return 0;
- }
-
- The basic motivation behind the circular_buffer was to create a container which would work
- seamlessly with STL. Additionally, the design of the circular_buffer was guided by the following
- principles:
-
-
-
Maximum efficiency for envisaged applications.
-
-
Suitable for general purpose use.
-
-
The behaviour of the buffer as intuitive as possible.
-
-
Suitable for specialization by means of adaptors. (The circular_buffer_space_optimized is such an example of the adaptor.)
-
A kind of cache storing a specified number of last inserted elements.
-
-
Efficient fixed capacity FIFO (First In, First Out) or LIFO (Last In, First Out) queue which removes the
- oldest (inserted as first) elements when full.
-
-
-
- The following paragraphs describe issues that had to be considered during the implementation of the
- circular_buffer:
-
- The thread-safety of the circular_buffer is the same as the thread-safety of containers in most STL
- implementations. This means the circular_buffer is thread-safe only in the sense that simultaneous
- accesses to distinct instances of the circular_buffer are safe, and simultaneous read accesses to a
- shared circular_buffer are safe.
-
-
- If multiple threads access a single circular_buffer, and at least one of the threads may potentially
- write, then the user is responsible for ensuring mutual exclusion between the threads during the container
- accesses. The mutual exclusion between the threads can be achieved by wrapping operations of the underlying
- circular_buffer with a lock acquisition and release. (See the Bounded
- Buffer Example.)
-
-
- Overwrite Operation
-
-
- Overwrite operation occurs when an element is inserted into a full circular_buffer - the old element
- is being overwritten by the new one. There was a discussion what exactly "overwriting of an element" means during
- the formal review. It may be either a destruction of the original element and a consequent inplace construction
- of a new element or it may be an assignment of a new element into an old one. The circular_buffer
- implements assignment because it is more effective.
-
-
- From the point of business logic of a stored element, the destruction/construction operation and assignment
- usually mean the same. However, in very rare cases (if in any) they may differ. If there is a requirement for
- elements to be destructed/constructed instead of being assigned, consider implementing a wrapper of the element
- which would implement the assign operator, and store the wrappers instead. It is necessary to note that storing
- such wrappers has a drawback. The destruction/construction will be invoked on every assignment of the wrapper -
- not only when a wrapper is being overwritten (when the buffer is full) but also when the stored wrappers are
- being shifted (e.g. as a result of insertion into the middle of container).
-
-
- Writing to a Full Buffer
-
-
- There are several options how to cope with the case if a data source produces more data than can fit in the
- fixed-sized buffer:
-
-
-
Inform the data source to wait until there is room in the buffer (e.g. by throwing an overflow exception).
-
-
If the oldest data is the most important, ignore new data from the source until there is room in the buffer
- again.
-
-
If the latest data is the most important, write over the oldest data.
-
-
Let the producer to be responsible for checking the size of the buffer prior writing into it.
-
-
-
- It is apparent that the circular_buffer implements the third option. But it may be less apparent it
- does not implement any other option - especially the first two. One can get an impression that the
- circular_buffer should implement first three options and offer a mechanism of choosing among them.
- This impression is wrong. The circular_buffer was designed and optimized to be circular (which means
- overwriting the oldest data when full). If such a controlling mechanism had been enabled, it would just
- complicate the matters and the usage of the circular_buffer would be probably less straightforward.
-
-
- Moreover, the first two options (and the fourth option as well) do not require the buffer to be circular at all.
- If there is a need for the first or second option, consider implementing an adaptor of e.g.
- std::vector. In this case the circular_buffer is not suitable for adapting, because, in
- contrary to std::vector, it bears an overhead for its circular behaviour.
-
-
- Reading/Removing from an Empty Buffer
-
-
- When reading or removing an element from an empty buffer, the buffer should be able to notify the data consumer
- (e.g. by throwing underflow exception) that there are no elements stored in it. The circular_buffer
- does not implement such a behaviour for two reasons:
-
-
-
It would introduce performance overhead.
-
-
No other std container implements it this way.
-
-
-
- It is considered to be a bug to read or remove an element (e.g. by calling front() or
- pop_back()) from an empty std container and from an empty circular_buffer
- as well. The data consumer has to test if the container is not empty before reading/removing from it. However,
- when reading from the circular_buffer, there is an option to rely on the at() method
- which throws an exception when the index is out of range.
-
-
- Iterator Invalidation
-
-
- An iterator is usually considered to be invalidated if an element, the iterator pointed to, had been removed or
- overwritten by an another element. This definition is enforced by the Debug Support and is
- documented for every method. However, some applications utilizing circular_buffer may require less
- strict definition: an iterator is invalid only if it points to an uninitialized memory. Consider following
- example:
-
-
- #define BOOST_CB_DISABLE_DEBUG // The Debug Support has to be disabled, otherwise the code produces a runtime error.
-
- #include <boost/circular_buffer.hpp>
- #include <assert.h>
-
- int main(int /*argc*/, char* /*argv*/[]) {
-
- boost::circular_buffer<int> cb(3);
-
- cb.push_back(1);
- cb.push_back(2);
- cb.push_back(3);
-
- boost::circular_buffer<int>::iterator it = cb.begin();
-
- assert(*it == 1);
-
- cb.push_back(4);
-
- assert(*it == 4); // The iterator still points to the initialized memory.
-
- return 0;
- }
-
-
- The iterator does not point to the original element any more (and is considered to be invalid from the "strict"
- point of view) but it still points to the same valid place in the memory. This "soft" definition of
- iterator invalidation is supported by the circular_buffer but should be considered as an
- implementation detail rather than a full-fledged feature. The rules when the iterator is still valid can be
- inferred from the code in soft_iterator_invalidation.cpp.
-
- The circular_buffer should not be used for storing pointers to dynamically allocated objects. When a
- circular_buffer becomes full, further insertion will overwrite the stored pointers - resulting in a
- memory leak. One recommend alternative is the use of smart pointers [1]. (Any
- container of std::auto_ptr is considered particularly hazardous. [2] )
-
-
- While internals of a circular_buffer are circular, iterators are not. Iterators of a
- circular_buffer are only valid for the range [begin(), end()]. E.g. iterators
- (begin() - 1) and (end() + 1) are invalid.
-
- In order to help a programmer to avoid and find common bugs, the circular_buffer contains a kind of
- debug support.
-
-
- The circular_buffer 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 (BOOST_ASSERT macros) which ensure the circular_buffer
- 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.
-
-
- Moreover, the uninitialized memory allocated by circular_buffer is filled with the value
- 0xcc 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 source code.
-
-
- The debug support is enabled only in the debug mode (when the NDEBUG is not defined). It can also be
- explicitly disabled by defining BOOST_CB_DISABLE_DEBUG macro.
-
- The following example includes various usage of the circular_buffer.
-
-
- #include <boost/circular_buffer.hpp>
- #include <numeric>
- #include <assert.h>
-
- int main(int /*argc*/, char* /*argv*/[])
- {
- // create a circular buffer of capacity 3
- boost::circular_buffer<int> cb(3);
-
- // insert some elements into the circular buffer
- cb.push_back(1);
- cb.push_back(2);
-
- // assertions
- assert(cb[0] == 1);
- assert(cb[1] == 2);
- assert(!cb.full());
- assert(cb.size() == 2);
- assert(cb.capacity() == 3);
-
- // insert some other elements
- cb.push_back(3);
- cb.push_back(4);
-
- // evaluate the sum
- int sum = std::accumulate(cb.begin(), cb.end(), 0);
-
- // assertions
- assert(cb[0] == 2);
- assert(cb[1] == 3);
- assert(cb[2] == 4);
- assert(*cb.begin() == 2);
- assert(cb.front() == 2);
- assert(cb.back() == 4);
- assert(sum == 9);
- assert(cb.full());
- assert(cb.size() == 3);
- assert(cb.capacity() == 3);
-
- return 0;
- }
-
-
- The circular_buffer has a capacity of three int. Therefore, the size of the buffer will
- not exceed three. The accumulate algorithm
- evaluates the sum of the stored elements. The semantics of the circular_buffer can be inferred from
- the assertions.
-
- The bounded buffer is normally used in a producer-consumer mode when producer threads produce items and store
- them in the container and consumer threads remove these items and process them. The bounded buffer has to
- guarantee that producers do not insert items into the container when the container is full, that consumers do not
- try to remove items when the container is empty, and that each produced item is consumed by exactly one consumer.
-
-
- The example below shows how the circular_buffer can be utilized as an underlying container of the
- bounded buffer.
-
- The push_front() method is called by the producer thread in order to insert a new item into the
- buffer. The method locks the mutex and waits until there is a space for the new item. (The mutex is unlocked
- during the waiting stage and has to be regained when the condition is met.) If there is a space in the buffer
- available, the execution continues and the method inserts the item at the end of the
- circular_buffer. Then it increments the number of unread items and unlocks the mutex (in case an
- exception is thrown before the mutex is unlocked, the mutex is unlocked automatically by the destructor of the
- scoped_lock). At last the method notifies one of the consumer threads waiting for a new item to be
- inserted into the buffer.
-
-
- The pop_back() method is called by the consumer thread in order to read the next item from the
- buffer. The method locks the mutex and waits until there is an unread item in the buffer. If there is at least
- one unread item, the method decrements the number of unread items and reads the next item from the
- circular_buffer. Then it unlocks the mutex and notifies one of the producer threads waiting for the
- buffer to free a space for the next item.
-
-
- The pop_back() method does not remove the item but the item is left in the
- circular_buffer which then replaces it with a new one (inserted by a producer) when the
- circular_buffer is full. This technique is more effective than removing the item explicitly by
- calling the pop_back() method of the circular_buffer. This claim is based on the
- assumption that an assignment (replacement) of a new item into an old one is more effective than a destruction
- (removal) of an old item and a consequent inplace construction (insertion) of a new item.
-
-
- For comparison of bounded buffers based on different containers compile and run bounded_buffer_comparison.cpp. The test should reveal the bounded
- buffer based on the circular_buffer is most effective closely followed by the
- std::deque based bounded buffer. (In praxis the result may be different because the test is affected
- by external factors such as immediate CPU load.)
-
- An array range. (A typedef for the std::pair where its first element is a pointer to
- a beginning of an array and its second element represents a size of the array.)
-
- A range of a const array. (A typedef for the std::pair where its first element is a pointer to
- a beginning of a const array and its second element represents a size of the const array.)
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
-
-
- Complexity:
-
-
- Constant.
-
-
-
-
- Note:
-
-
- This constructor has been defined only due to compatibility with the STL container definition. Avoid
- using it because it may allocate very large amount of memory.
-
-
-
-
-
-
- explicit
- circular_buffer(capacity_type capacity, const
- allocator_type& alloc =
- allocator_type());
-
- Create an empty circular_buffer with the specified capacity.
-
- The maximum number of elements which can be stored in the circular_buffer.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
-
-
- Complexity:
-
-
- Constant.
-
-
-
-
-
-
- circular_buffer(size_type n, const_reference item, const
- allocator_type& alloc =
- allocator_type());
-
- Create a full circular_buffer with the specified capacity and filled with n
- copies of item.
-
- The number of elements the created circular_buffer will be filled with.
-
-
-
-
-
-
- item
-
-
- The element the created circular_buffer will be filled with.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the n).
-
-
-
-
-
-
- circular_buffer(capacity_type capacity, size_type n, const_reference item, const
- allocator_type& alloc =
- allocator_type());
-
- Create a circular_buffer with the specified capacity and filled with n copies of
- item.
-
- Creates a copy of the specified circular_buffer.
-
-
-
- Effect:
-
-
- *this == cb
-
-
-
-
- Parameter(s):
-
-
-
-
- cb
-
-
- The circular_buffer to be copied.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the size of cb).
-
-
-
-
-
-
- template <class
- InputIterator>
- circular_buffer(InputIterator first, InputIterator last, const allocator_type& alloc =
- allocator_type());
-
- Create a full circular_buffer filled with a copy of the range.
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the std::distance(first, last)).
-
-
-
-
-
-
- template <class
- InputIterator>
- circular_buffer(capacity_type capacity,
- InputIterator first, InputIterator last, const allocator_type& alloc =
- allocator_type());
-
- Create a circular_buffer with the specified capacity and filled with a copy of the range.
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity && size() <=
- std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] == *(last -
- capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)
-
- If the number of items to be copied from the range [first, last) is greater than the
- specified capacity then only elements from the range [last - capacity, last)
- will be copied.
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity
-
-
- The capacity of the created circular_buffer.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be copied.
-
-
-
-
-
-
- last
-
-
- The end of the range to be copied.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in std::distance(first, last); in min[capacity, std::distance(first,
- last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
-
-
- ~circular_buffer();
-
-
- The destructor.
-
- Destroys the circular_buffer.
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (including iterators equal to
- end()).
-
- iterator begin();
-
- Get the iterator pointing to the beginning of the circular_buffer.
-
-
- Returns:
-
-
- A random access iterator pointing to the first element of the circular_buffer. If the
- circular_buffer is empty it returns an iterator equal to the one returned by
- end().
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- iterator end();
-
- Get the iterator pointing to the end of the circular_buffer.
-
-
- Returns:
-
-
- A random access iterator pointing to the element "one behind" the last element of the
- circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by begin().
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_iterator begin()
- const;
-
- Get the const iterator pointing to the beginning of the circular_buffer.
-
-
- Returns:
-
-
- A const random access iterator pointing to the first element of the circular_buffer. If
- the circular_buffer is empty it returns an iterator equal to the one returned by
- end()
- const.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_iterator end()
- const;
-
- Get the const iterator pointing to the end of the circular_buffer.
-
-
- Returns:
-
-
- A const random access iterator pointing to the element "one behind" the last element of the
- circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by begin() const const.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- reverse_iterator
- rbegin();
-
- Get the iterator pointing to the beginning of the "reversed" circular_buffer.
-
-
- Returns:
-
-
- A reverse random access iterator pointing to the last element of the circular_buffer. If
- the circular_buffer is empty it returns an iterator equal to the one returned by
- rend().
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- reverse_iterator
- rend();
-
- Get the iterator pointing to the end of the "reversed" circular_buffer.
-
-
- Returns:
-
-
- A reverse random access iterator pointing to the element "one before" the first element of the
- circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rbegin().
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_reverse_iterator rbegin()
- const;
-
- Get the const iterator pointing to the beginning of the "reversed" circular_buffer.
-
-
- Returns:
-
-
- A const reverse random access iterator pointing to the last element of the
- circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rend() const.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_reverse_iterator rend()
- const;
-
- Get the const iterator pointing to the end of the "reversed" circular_buffer.
-
-
- Returns:
-
-
- A const reverse random access iterator pointing to the element "one before" the first element of the
- circular_buffer. If the circular_buffer is empty it returns an iterator equal
- to the one returned by rbegin() const.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- array_range
- array_one();
-
- Get the first continuous array of the internal buffer.
-
- This method in combination with array_two() can be useful
- when passing the stored data into a legacy C API as an array. Suppose there is a
- circular_buffer of capacity 10, containing 7 characters 'a', 'b', ..., 'g'
- where buff[0] == 'a', buff[1] == 'b', ... and buff[6] == 'g':
-
- circular_buffer<char> buff(10);
-
- The internal representation is often not linear and the state of the internal buffer may look like
- this:
-
- |e|f|g| | | |a|b|c|d|
- end ---^
- begin -------^
-
- where |a|b|c|d| represents the "array one", |e|f|g| represents the "array two"
- and | | | | is a free space.
- Now consider a typical C style function for writing data into a file:
-
- int write(int file_desc, char* buff, int num_bytes);
-
- There are two ways how to write the content of the circular_buffer into a file. Either
- relying on array_one() and
- array_two()
- methods and calling the write function twice:
-
- array_range ar = buff.array_one();
- write(file_desc, ar.first, ar.second);
- ar = buff.array_two();
- write(file_desc, ar.first, ar.second);
-
- Or relying on the linearize() method:
-
- write(file_desc, buff.linearize(), buff.size());
-
- Since the complexity of array_one() and
- array_two()
- methods is constant the first option is suitable when calling the write method is "cheap". On the other
- hand the second option is more suitable when calling the write method is more "expensive" than calling
- the linearize() method whose
- complexity is linear.
-
-
-
- Returns:
-
-
- The array range of the first continuous array of the internal buffer. In the case the
- circular_buffer is empty the size of the returned array is 0.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
-
-
-
- Warning:
-
-
- In general invoking any method which modifies the internal state of the circular_buffer may delinearize
- the internal buffer and invalidate the array ranges returned by array_one() and
- array_two() (and their
- const versions).
-
-
-
-
- Note:
-
-
- In the case the internal buffer is linear e.g. |a|b|c|d|e|f|g| | | | the "array one" is
- represented by |a|b|c|d|e|f|g| and the "array two" does not exist (the array_two() method
- returns an array with the size 0).
-
- array_range
- array_two();
-
- Get the second continuous array of the internal buffer.
-
- This method in combination with array_one() can be useful
- when passing the stored data into a legacy C API as an array.
-
-
-
- Returns:
-
-
- The array range of the second continuous array of the internal buffer. In the case the internal buffer
- is linear or the circular_buffer is empty the size of the returned array is
- 0.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_array_range array_one()
- const;
-
- Get the first continuous array of the internal buffer.
-
- This method in combination with array_two() const can be
- useful when passing the stored data into a legacy C API as an array.
-
-
-
- Returns:
-
-
- The array range of the first continuous array of the internal buffer. In the case the
- circular_buffer is empty the size of the returned array is 0.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- const_array_range array_two()
- const;
-
- Get the second continuous array of the internal buffer.
-
- This method in combination with array_one() const can be
- useful when passing the stored data into a legacy C API as an array.
-
-
-
- Returns:
-
-
- The array range of the second continuous array of the internal buffer. In the case the internal buffer
- is linear or the circular_buffer is empty the size of the returned array is
- 0.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- A pointer to the beginning of the array or 0 if empty.
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end());
- does not invalidate any iterators if the postcondition (the Effect) is already met prior calling
- this method.
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer); constant if the postcondition (the
- Effect) is already met.
-
-
-
-
- Warning:
-
-
- In general invoking any method which modifies the internal state of the circular_buffer
- may delinearize the internal buffer and invalidate the returned pointer.
-
-
-
-
- See Also:
-
-
- array_one() and
- array_two() for the
- other option how to pass data into a legacy C API.
-
-
-
-
-
-
- size_type size()
- const;
-
- Get the number of elements currently stored in the circular_buffer.
-
-
- Returns:
-
-
- The number of elements stored in the circular_buffer.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- size_type reserve()
- const;
-
- Get the maximum number of elements which can be inserted into the circular_buffer without
- overwriting any of already stored elements.
-
- void set_capacity(capacity_type
- new_capacity);
-
- Change the capacity of the circular_buffer.
-
-
- Effect:
-
-
- capacity() ==
- new_capacity && size() <=
- new_capacity
-
- If the current number of elements stored in the circular_buffer is greater than the
- desired new capacity then number of [size() - new_capacity]
- last elements will be removed and the new size will be equal to new_capacity.
-
-
-
-
- Parameter(s):
-
-
-
-
- new_capacity
-
-
- The new capacity.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Strong.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end()) if
- the new capacity is different from the original.
-
- void resize(size_type new_size, const_reference item =
- value_type());
-
- Change the size of the circular_buffer.
-
-
- Effect:
-
-
- size() ==
- new_size && capacity() >=
- new_size
-
- If the new size is greater than the current size, copies of item will be inserted at the
- back of the of the circular_buffer in order to achieve the desired size. In the
- case the resulting size exceeds the current capacity the capacity will be set to
- new_size.
- If the current number of elements stored in the circular_buffer is greater than the
- desired new size then number of [size() - new_size]
- last elements will be removed. (The capacity will remain unchanged.)
-
-
-
-
- Parameter(s):
-
-
-
-
- new_size
-
-
- The new size.
-
-
-
-
-
-
- item
-
-
- The element the circular_buffer will be filled with in order to gain the requested
- size. (See the Effect.)
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end()) if
- the new size is greater than the current capacity. Invalidates iterators pointing to the removed
- elements if the new size is lower that the original size. Otherwise it does not invalidate any
- iterator.
-
-
-
-
- Complexity:
-
-
- Linear (in the new size of the circular_buffer).
-
- void rset_capacity(capacity_type
- new_capacity);
-
- Change the capacity of the circular_buffer.
-
-
- Effect:
-
-
- capacity() ==
- new_capacity && size() <=
- new_capacity
-
- If the current number of elements stored in the circular_buffer is greater than the
- desired new capacity then number of [size() - new_capacity]
- first elements will be removed and the new size will be equal to new_capacity.
-
-
-
-
- Parameter(s):
-
-
-
-
- new_capacity
-
-
- The new capacity.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Strong.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end()) if
- the new capacity is different from the original.
-
- void rresize(size_type new_size, const_reference item =
- value_type());
-
- Change the size of the circular_buffer.
-
-
- Effect:
-
-
- size() ==
- new_size && capacity() >=
- new_size
-
- If the new size is greater than the current size, copies of item will be inserted at the
- front of the of the circular_buffer in order to achieve the desired size. In the
- case the resulting size exceeds the current capacity the capacity will be set to
- new_size.
- If the current number of elements stored in the circular_buffer is greater than the
- desired new size then number of [size() - new_size]
- first elements will be removed. (The capacity will remain unchanged.)
-
-
-
-
- Parameter(s):
-
-
-
-
- new_size
-
-
- The new size.
-
-
-
-
-
-
- item
-
-
- The element the circular_buffer will be filled with in order to gain the requested
- size. (See the Effect.)
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end()) if
- the new size is greater than the current capacity. Invalidates iterators pointing to the removed
- elements if the new size is lower that the original size. Otherwise it does not invalidate any
- iterator.
-
-
-
-
- Complexity:
-
-
- Linear (in the new size of the circular_buffer).
-
- The capacity of the circular_buffer will be set to the specified value and the content of
- the circular_buffer will be removed and replaced with n copies of the
- item.
-
- template <class
- InputIterator>
- void assign(capacity_type capacity,
- InputIterator first, InputIterator last);
-
- Assign a copy of the range into the circular_buffer specifying the capacity.
-
- The capacity of the circular_buffer will be set to the specified value and the content of
- the circular_buffer will be removed and replaced with copies of elements from the specified
- range.
-
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity && size() <=
- std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] == *(last -
- capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)
-
- If the number of items to be copied from the range [first, last) is greater than the
- specified capacity then only elements from the range [last - capacity, last)
- will be copied.
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity
-
-
- The new capacity.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be copied.
-
-
-
-
-
-
- last
-
-
- The end of the range to be copied.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to
- end()).
-
-
-
-
- Complexity:
-
-
- Linear (in std::distance(first, last); in min[capacity, std::distance(first,
- last)] if the InputIterator is a RandomAccessIterator).
-
- void
- swap(circular_buffer<T,Alloc>& cb);
-
- Swap the contents of two circular_buffers.
-
-
- Effect:
-
-
- this contains elements of cb and vice versa; the capacity of
- this equals to the capacity of cb and vice versa.
-
-
-
-
- Parameter(s):
-
-
-
-
- cb
-
-
- The circular_buffer whose content will be swapped.
-
-
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators of both circular_buffers. (On the other hand the iterators still
- point to the same elements but within another container. If you want to rely on this feature you have
- to turn the Debug Support off otherwise an assertion will report an error if such
- invalidated iterator is used.)
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- void push_back(const_reference item =
- value_type());
-
- Insert a new element at the end of the circular_buffer.
-
-
- Effect:
-
-
- if capacity()
- > 0 then back() == item
- If the circular_buffer is full, the first element will be removed. If the capacity is
- 0, nothing will be inserted.
-
-
-
-
- Parameter(s):
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- void push_front(const_reference item =
- value_type());
-
- Insert a new element at the beginning of the circular_buffer.
-
-
- Effect:
-
-
- if capacity()
- > 0 then front() == item
- If the circular_buffer is full, the last element will be removed. If the capacity is
- 0, nothing will be inserted.
-
-
-
-
- Parameter(s):
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer).
-
- pos is a valid iterator pointing to the circular_buffer or its end.
-
-
-
-
- Effect:
-
-
- The item will be inserted at the position pos.
- If the circular_buffer is full, the first element will be overwritten. If the
- circular_buffer is full and the pos points to begin(), then the
- item will not be inserted. If the capacity is 0, nothing will be inserted.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the item will be inserted.
-
-
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the inserted element or begin() if the
- item is not inserted. (See the Effect.)
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements at the insertion point (including pos) and
- iterators behind the insertion point (towards the end; except iterators equal to end()). It also
- invalidates iterators pointing to the overwritten element.
-
- pos is a valid iterator pointing to the circular_buffer or its end.
-
-
-
-
- Effect:
-
-
- The number of min[n, (pos - begin()) + reserve()] elements will
- be inserted at the position pos.
- The number of min[pos - begin(), max[0, n - reserve()]] elements
- will be overwritten at the beginning of the circular_buffer.
- (See Example for the explanation.)
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the items will be inserted.
-
-
-
-
-
-
- n
-
-
- The number of items the to be inserted.
-
-
-
-
-
-
- item
-
-
- The element whose copies will be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements at the insertion point (including pos) and
- iterators behind the insertion point (towards the end; except iterators equal to end()). It also
- invalidates iterators pointing to the overwritten elements.
-
-
-
-
- Complexity:
-
-
- Linear (in min[capacity(), std::distance(pos,
- end()) + n]).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer
- may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting 5 elements at the position p:
-
- insert(p, (size_t)5, 0);
-
- actually only 4 elements get inserted and elements 1 and 2 are overwritten.
- This is due to the fact the insert operation preserves the capacity. After insertion the internal
- buffer looks like this:
-
- |0|0|0|0|3|4|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|0|0|0|0|0|3|4|.
-
- template <class
- InputIterator>
- void insert(iterator
- pos, InputIterator first, InputIterator last);
-
- Insert the range [first, last) at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer or its end.
- Valid range [first, last) where first and last meet the
- requirements of an InputIterator.
-
-
-
-
- Effect:
-
-
- Elements from the range [first + max[0, distance(first, last) - (pos - begin()) - reserve()], last) will
- be inserted at the position pos.
- The number of min[pos - begin(), max[0, distance(first,
- last) - reserve()]] elements
- will be overwritten at the beginning of the circular_buffer.
- (See Example for the explanation.)
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the range will be inserted.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be inserted.
-
-
-
-
-
-
- last
-
-
- The end of the range to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements at the insertion point (including pos) and
- iterators behind the insertion point (towards the end; except iterators equal to end()). It also
- invalidates iterators pointing to the overwritten elements.
-
-
-
-
- Complexity:
-
-
- Linear (in [std::distance(pos, end()) + std::distance(first,
- last)]; in min[capacity(), std::distance(pos,
- end()) +
- std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer
- may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting a range of elements at the position p:
-
- int array[] = { 5, 6, 7, 8, 9 };
- insert(p, array, array + 5);
-
- actually only elements 6, 7, 8 and 9 from the
- specified range get inserted and elements 1 and 2 are overwritten. This is
- due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks
- like this:
-
- |6|7|8|9|3|4|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|5|6|7|8|9|3|4|.
-
- iterator rinsert(iterator pos, const_reference item =
- value_type());
-
- Insert an element before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer or its end.
-
-
-
-
- Effect:
-
-
- The item will be inserted before the position pos.
- If the circular_buffer is full, the last element will be overwritten. If the
- circular_buffer is full and the pos points to end(), then the
- item will not be inserted. If the capacity is 0, nothing will be inserted.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position before which the item will be inserted.
-
-
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the inserted element or end() if the
- item is not inserted. (See the Effect.)
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
- excluding pos). It also invalidates iterators pointing to the overwritten element.
-
- void rinsert(iterator pos, size_type n, const_reference
- item);
-
- Insert n copies of the item before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer or its end.
-
-
-
-
- Effect:
-
-
- The number of min[n, (end() - pos) + reserve()] elements will
- be inserted before the position pos.
- The number of min[end() - pos, max[0, n -
- reserve()]]
- elements will be overwritten at the end of the circular_buffer.
- (See Example for the explanation.)
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the items will be inserted.
-
-
-
-
-
-
- n
-
-
- The number of items the to be inserted.
-
-
-
-
-
-
- item
-
-
- The element whose copies will be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
- excluding pos). It also invalidates iterators pointing to the overwritten elements.
-
-
-
-
- Complexity:
-
-
- Linear (in min[capacity(),
- std::distance(begin(),
- pos) + n]).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer
- may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting 5 elements before the position p:
-
- rinsert(p, (size_t)5, 0);
-
- actually only 4 elements get inserted and elements 3 and 4 are overwritten.
- This is due to the fact the rinsert operation preserves the capacity. After insertion the internal
- buffer looks like this:
-
- |1|2|0|0|0|0|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|0|0|0|0|0|3|4|.
-
- template <class
- InputIterator>
- void rinsert(iterator
- pos, InputIterator first, InputIterator last);
-
- Insert the range [first, last) before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer or its end.
- Valid range [first, last) where first and last meet the
- requirements of an InputIterator.
-
-
-
-
- Effect:
-
-
- Elements from the range [first, last - max[0, distance(first, last) - (end() - pos) - reserve()]) will be
- inserted before the position pos.
- The number of min[end() - pos, max[0,
- distance(first, last) - reserve()]] elements
- will be overwritten at the end of the circular_buffer.
- (See Example for the explanation.)
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the range will be inserted.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be inserted.
-
-
-
-
-
-
- last
-
-
- The end of the range to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operations in the Throws section do not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
- excluding pos). It also invalidates iterators pointing to the overwritten elements.
-
-
-
-
- Complexity:
-
-
- Linear (in [std::distance(begin(), pos) +
- std::distance(first, last)]; in min[capacity(),
- std::distance(begin(),
- pos) + std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer
- may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting a range of elements before the position p:
-
- int array[] = { 5, 6, 7, 8, 9 };
- insert(p, array, array + 5);
-
- actually only elements 5, 6, 7 and 8 from the
- specified range get inserted and elements 3 and 4 are overwritten. This is
- due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks
- like this:
-
- |1|2|5|6|7|8|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|5|6|7|8|9|3|4|.
-
- iterator erase(iterator pos);
-
- Remove an element at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer (but not an
- end()).
-
-
-
-
- Effect:
-
-
- The element at the position pos is removed.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator pointing at the element to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining beyond the removed element or end() if no such element
- exists.
-
-
-
-
- Throws:
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the erased element and iterators pointing to the elements behind the
- erased element (towards the end; except iterators equal to end()).
-
- The elements from the range [first, last) are removed. (If first == last
- nothing is removed.)
-
-
-
-
- Parameter(s):
-
-
-
-
- first
-
-
- The beginning of the range to be removed.
-
-
-
-
-
-
- last
-
-
- The end of the range to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining beyond the removed elements or end() if no such element
- exists.
-
-
-
-
- Throws:
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the erased elements and iterators pointing to the elements behind the
- erased range (towards the end; except iterators equal to end()).
-
- iterator rerase(iterator pos);
-
- Remove an element at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer (but not an
- end()).
-
-
-
-
- Effect:
-
-
- The element at the position pos is removed.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator pointing at the element to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining in front of the removed element or begin() if no such
- element exists.
-
-
-
-
- Throws:
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the erased element and iterators pointing to the elements in front of
- the erased element (towards the beginning).
-
- The elements from the range [first, last) are removed. (If first == last
- nothing is removed.)
-
-
-
-
- Parameter(s):
-
-
-
-
- first
-
-
- The beginning of the range to be removed.
-
-
-
-
-
-
- last
-
-
- The end of the range to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining in front of the removed elements or begin() if no such
- element exists.
-
-
-
-
- Throws:
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic; no-throw if the operation in the Throws section does not throw anything.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates iterators pointing to the erased elements and iterators pointing to the elements in front
- of the erased range (towards the beginning).
-
- template <class T, class Alloc>
- bool operator==(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if they are equal.
-
- template <class T, class Alloc>
- bool operator<(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if the left one is lesser than
- the right one.
-
- template <class T, class Alloc>
- bool operator!=(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if they are non-equal.
-
- template <class T, class Alloc>
- bool operator>(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if the left one is greater than
- the right one.
-
- template <class T, class Alloc>
- bool operator<=(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if the left one is lesser or
- equal to the right one.
-
- template <class T, class Alloc>
- bool operator>=(const circular_buffer<T,Alloc>& lhs, const
- circular_buffer<T,Alloc>& rhs);
-
- Compare two circular_buffers element-by-element to determine if the left one is greater or
- equal to the right one.
-
- template <class T, class Alloc>
- void swap(circular_buffer<T,Alloc>& lhs, circular_buffer<T,Alloc>&
- rhs);
-
- Swap the contents of two circular_buffers.
-
-
- Effect:
-
-
- lhs contains elements of rhs and vice versa.
-
-
-
-
- Parameter(s):
-
-
-
-
- lhs
-
-
- The circular_buffer whose content will be swapped with rhs.
-
-
-
-
-
-
- rhs
-
-
- The circular_buffer whose content will be swapped with lhs.
-
-
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffers).
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators of both circular_buffers. (On the other hand the iterators still
- point to the same elements but within another container. If you want to rely on this feature you have
- to turn the Debug Support off otherwise an assertion will report an error if such
- invalidated iterator is used.)
-
- A good implementation of smart pointers is included in Boost.
-
-
-
-
-
- Never create a circular buffer of std::auto_ptr. Refer to Scott Meyers ' excellent book Effective STL for a detailed discussion.
- (Meyers S., Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library.
- Addison-Wesley, 2001.)
-
- The circular_buffer has a short history. Its first version was a std::deque 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.
-
-
- The second version adapted std::vector but it has been abandoned soon because of limited control
- over iterator invalidation.
-
-
- 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.
-
- Use, modification, and distribution is subject to the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
- The circular_buffer_space_optimized container is an adaptor of the circular_buffer. The functionality of the
- circular_buffer_space_optimized is similar to the base circular_buffer except it does
- not allocate memory at once when created rather it allocates memory as needed. (The predictive memory allocation
- is similar to typical std::vector implementation.) Moreover the memory is automatically freed as the
- size of the container decreases.
-
-
-
-
-
-
-
-
-
-
- Figure:
-
-
- The memory allocation process of the space optimized circular buffer. The min_capacity() of the
- capacity controller represents the minimal guaranteed amount of allocated memory. The
- allocated memory will never drop under this value. The default value of the min_capacity() is
- set to 0.
-
- 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 circular_buffer_space_optimized will result in decreased memory consumption and can improve
- the CPU cache effectiveness.
-
- The circular_buffer_space_optimized is defined in the file boost/circular_buffer.hpp. There is also a forward declaration
- for the circular_buffer_space_optimized in the header file boost/circular_buffer_fwd.hpp.
-
- Following public types are specific to the circular_buffer_space_optimized. Description of the
- public types common with the circular_buffer can be found in the circular_buffer's
- documentation.
-
The capacity()
- represents the capacity of the circular_buffer_space_optimized and the
- min_capacity() determines the minimal allocated size of its internal buffer. The converting
- constructor of the capacity_control allows implicit conversion from
- size_type-like types which ensures compatibility of creating an instance of the
- circular_buffer_space_optimized with other STL containers. On the other hand the operator
- size_type() provides implicit conversion to the size_type which allows to treat
- the capacity of the circular_buffer_space_optimized the same way as in the circular_buffer.
-
- explicit
- circular_buffer_space_optimized(const allocator_type&
- alloc = allocator_type());
-
- Create an empty space optimized circular buffer with a maximum capacity.
-
-
- Effect:
-
-
- capacity().capacity()
- == max_size()
- && capacity().min_capacity()
- == 0 && size() ==
- 0
-
- There is no memory allocated in the internal buffer.
-
-
-
-
- Parameter(s):
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Complexity:
-
-
- Constant.
-
-
-
-
-
-
- explicit
- circular_buffer_space_optimized(capacity_type
- capacity_ctrl, const allocator_type&
- alloc = allocator_type());
-
- Create an empty space optimized circular buffer with the specified capacity.
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size() ==
- 0
-
- The amount of allocated memory in the internal buffer is capacity_ctrl.min_capacity().
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The capacity controller representing the maximum number of elements which can be stored in the
- circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
-
-
- Complexity:
-
-
- Constant.
-
-
-
-
-
-
- circular_buffer_space_optimized(capacity_type
- capacity_ctrl, const_reference
- item, const allocator_type&
- alloc = allocator_type());
-
- Create a full space optimized circular buffer with the specified capacity filled with
- capacity_ctrl.capacity() copies of item.
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && full()
- && (*this)[0] == item && (*this)[1] == item && ... && (*this)
- [capacity_ctrl.capacity() - 1] == item
-
- The amount of allocated memory in the internal buffer is capacity_ctrl.capacity().
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The capacity controller representing the maximum number of elements which can be stored in the
- circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
-
-
-
-
-
-
- item
-
-
- The element the created circular_buffer_space_optimized will be filled with.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the capacity_ctrl.capacity()).
-
-
-
-
-
-
- circular_buffer_space_optimized(capacity_type
- capacity_ctrl, size_type n,
- const_reference
- item, const allocator_type&
- alloc = allocator_type());
-
- Create a space optimized circular buffer with the specified capacity filled with n copies of
- item.
-
-
- Precondition:
-
-
- capacity_ctrl.capacity() >= n
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size() == n
- && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] ==
- item
-
- The amount of allocated memory in the internal buffer is max[n,
- capacity_ctrl.min_capacity()].
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The capacity controller representing the maximum number of elements which can be stored in the
- circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
-
-
-
-
-
-
- n
-
-
- The number of elements the created circular_buffer_space_optimized will be filled
- with.
-
-
-
-
-
-
- item
-
-
- The element the created circular_buffer_space_optimized will be filled with.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
- Creates a copy of the specified circular_buffer_space_optimized.
-
-
-
- Effect:
-
-
- *this == cb
-
- The amount of allocated memory in the internal buffer is cb.size().
-
-
-
-
- Parameter(s):
-
-
-
-
- cb
-
-
- The circular_buffer_space_optimized to be copied.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the size of cb).
-
-
-
-
-
-
- template
- <class InputIterator>
- circular_buffer_space_optimized(InputIterator first, InputIterator last, const allocator_type&
- alloc = allocator_type());
-
- Create a full space optimized circular buffer filled with a copy of the range.
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
-
-
-
- Effect:
-
-
- capacity().capacity()
- == std::distance(first, last) && capacity().min_capacity()
- == 0 && full()
- && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... &&
- (*this)[std::distance(first, last) - 1] == *(last - 1)
-
- The amount of allocated memory in the internal buffer is std::distance(first, last).
-
-
-
-
- Parameter(s):
-
-
-
-
- first
-
-
- The beginning of the range to be copied.
-
-
-
-
-
-
- last
-
-
- The end of the range to be copied.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in the std::distance(first, last)).
-
-
-
-
-
-
- template
- <class InputIterator>
- circular_buffer_space_optimized(capacity_type
- capacity_ctrl, InputIterator first, InputIterator last, const allocator_type&
- alloc = allocator_type());
-
- Create a space optimized circular buffer with the specified capacity (and the minimal guaranteed amount of
- allocated memory) filled with a copy of the range.
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size()
- <= std::distance(first, last) && (*this)[0]== (last - capacity_ctrl.capacity()) &&
- (*this)[1] == *(last - capacity_ctrl.capacity() + 1) && ... &&
- (*this)[capacity_ctrl.capacity() - 1] == *(last - 1)
-
- If the number of items to be copied from the range [first, last) is greater than the
- specified capacity_ctrl.capacity() then only elements from the range [last -
- capacity_ctrl.capacity(), last) will be copied.
-
- The amount of allocated memory in the internal buffer is max[capacity_ctrl.min_capacity(),
- min[capacity_ctrl.capacity(), std::distance(first, last)]].
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The capacity controller representing the maximum number of elements which can be stored in the
- circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be copied.
-
-
-
-
-
-
- last
-
-
- The end of the range to be copied.
-
-
-
-
-
-
- alloc
-
-
- The allocator.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Complexity:
-
-
- Linear (in std::distance(first, last); in min[capacity_ctrl.capacity(),
- std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
-
-
- ~circular_buffer_space_optimized();
-
-
- The destructor.
-
- Destroys the circular_buffer_space_optimized.
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (including
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- Following public member functions of the circular_buffer_space_optimized have different behaviour
- from the base circular_buffer. Description of the public member functions with the same behaviour
- can be found in the circular_buffer's documentation.
-
-
-
-
-
- bool
- full() const;
-
- Is the circular_buffer_space_optimized full?
-
-
- Returns:
-
-
- true if the number of elements stored in the circular_buffer_space_optimized
- equals the capacity of the circular_buffer_space_optimized; false otherwise.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer_space_optimized).
-
- size_type
- reserve() const;
-
- Get the maximum number of elements which can be inserted into the
- circular_buffer_space_optimized without overwriting any of already stored elements.
-
- const
- capacity_type&
- capacity() const;
-
- Get the capacity of the circular_buffer_space_optimized.
-
-
- Returns:
-
-
- The capacity controller representing the maximum number of elements which can be stored in the
- circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Does not invalidate any iterators.
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer_space_optimized).
-
- void
- set_capacity(const capacity_type&
- capacity_ctrl);
-
- Change the capacity (and the minimal guaranteed amount of allocated memory) of the
- circular_buffer_space_optimized.
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size()
- <= capacity_ctrl.capacity()
-
- If the current number of elements stored in the circular_buffer_space_optimized is greater
- than the desired new capacity then number of [size() -
- capacity_ctrl.capacity()]last elements will be removed and the new size will be equal to
- capacity_ctrl.capacity().
-
- If the current number of elements stored in the circular_buffer_space_optimized is lower
- than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as
- necessary but it will never drop below capacity_ctrl.min_capacity().
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The new capacity controller.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Strong.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in min[size(),
- capacity_ctrl.capacity()]).
-
-
-
-
- Note:
-
-
- To explicitly clear the extra allocated memory use the shrink-to-fit technique:
-
- boost::circular_buffer_space_optimized<int>
- cb(1000);
- ...
- boost::circular_buffer_space_optimized<int>(cb).swap(cb);
-
-
- For more information about the shrink-to-fit technique in STL see http://www.gotw.ca/gotw/054.htm.
-
- void
- resize(size_type
- new_size, const_reference
- item = value_type());
-
- Change the size of the circular_buffer_space_optimized.
-
-
- Effect:
-
-
- size() ==
- new_size && capacity().capacity()
- >= new_size
-
- If the new size is greater than the current size, copies of item will be inserted at the
- back of the of the circular_buffer_space_optimized in order to achieve the desired
- size. In the case the resulting size exceeds the current capacity the capacity will be set to
- new_size.
-
- If the current number of elements stored in the circular_buffer_space_optimized is greater
- than the desired new size then number of [size() -
- new_size]last elements will be removed. (The capacity will remain unchanged.)
-
- The amount of allocated memory in the internal buffer may be accommodated as necessary.
-
-
-
-
- Parameter(s):
-
-
-
-
- new_size
-
-
- The new size.
-
-
-
-
-
-
- item
-
-
- The element the circular_buffer_space_optimized will be filled with in order to gain
- the requested size. (See the Effect.)
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the new size of the circular_buffer_space_optimized).
-
- void
- rset_capacity(const capacity_type&
- capacity_ctrl);
-
- Change the capacity (and the minimal guaranteed amount of allocated memory) of the
- circular_buffer_space_optimized.
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size()
- <= capacity_ctrl
-
- If the current number of elements stored in the circular_buffer_space_optimized is greater
- than the desired new capacity then number of [size() -
- capacity_ctrl.capacity()]first elements will be removed and the new size will be equal
- to capacity_ctrl.capacity().
-
- If the current number of elements stored in the circular_buffer_space_optimized is lower
- than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as
- necessary but it will never drop below capacity_ctrl.min_capacity().
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The new capacity controller.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Strong.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in min[size(),
- capacity_ctrl.capacity()]).
-
- void
- rresize(size_type
- new_size, const_reference
- item = value_type());
-
- Change the size of the circular_buffer_space_optimized.
-
-
- Effect:
-
-
- size() ==
- new_size && capacity().capacity()
- >= new_size
-
- If the new size is greater than the current size, copies of item will be inserted at the
- front of the of the circular_buffer_space_optimized in order to achieve the desired
- size. In the case the resulting size exceeds the current capacity the capacity will be set to
- new_size.
-
- If the current number of elements stored in the circular_buffer_space_optimized is greater
- than the desired new size then number of [size() -
- new_size]first elements will be removed. (The capacity will remain unchanged.)
-
- The amount of allocated memory in the internal buffer may be accommodated as necessary.
-
-
-
-
- Parameter(s):
-
-
-
-
- new_size
-
-
- The new size.
-
-
-
-
-
-
- item
-
-
- The element the circular_buffer_space_optimized will be filled with in order to gain
- the requested size. (See the Effect.)
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the new size of the circular_buffer_space_optimized).
-
- void
- assign(capacity_type
- capacity_ctrl, size_type n,
- const_reference
- item);
-
- Assign n items into the space optimized circular buffer specifying the capacity.
-
- The capacity of the circular_buffer_space_optimized will be set to the specified value and
- the content of the circular_buffer_space_optimized will be removed and replaced with
- n copies of the item.
-
-
-
- Precondition:
-
-
- capacity_ctrl.capacity() >= n
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size() == n
- && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1]
- == item
-
- The amount of allocated memory will be max[n, capacity_ctrl.min_capacity()].
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The new capacity controller.
-
-
-
-
-
-
- n
-
-
- The number of elements the circular_buffer_space_optimized will be filled with.
-
-
-
-
-
-
- item
-
-
- The element the circular_buffer_space_optimized will be filled with.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
- template
- <class InputIterator>
- void assign(InputIterator first, InputIterator last);
-
- Assign a copy of the range into the space optimized circular buffer.
-
- The content of the circular_buffer_space_optimized will be removed and replaced with copies
- of elements from the specified range.
-
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
- template
- <class InputIterator>
- void assign(capacity_type
- capacity_ctrl, InputIterator first, InputIterator last);
-
- Assign a copy of the range into the space optimized circular buffer specifying the capacity.
-
- The capacity of the circular_buffer_space_optimized will be set to the specified value and
- the content of the circular_buffer_space_optimized will be removed and replaced with copies
- of elements from the specified range.
-
-
-
- Precondition:
-
-
- Valid range [first, last).
- first and last have to meet the requirements of InputIterator.
-
-
-
-
- Effect:
-
-
- capacity() ==
- capacity_ctrl && size()
- <= std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] ==
- *(last - capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)
-
- If the number of items to be copied from the range [first, last) is greater than the
- specified capacity then only elements from the range [last - capacity, last)
- will be copied.
-
- The amount of allocated memory in the internal buffer is max[std::distance(first, last),
- capacity_ctrl.min_capacity()].
-
-
-
-
- Parameter(s):
-
-
-
-
- capacity_ctrl
-
-
- The new capacity controller.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be copied.
-
-
-
-
-
-
- last
-
-
- The end of the range to be copied.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in std::distance(first, last); in min[capacity_ctrl.capacity(),
- std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
- void
- swap(circular_buffer_space_optimized<T,Alloc>& cb);
-
- Swap the contents of two space optimized circular buffers.
-
-
- Effect:
-
-
- this contains elements of cb and vice versa; the capacity and the amount of
- allocated memory in the internal buffer of this equal to the capacity and the amount of
- allocated memory of cb and vice versa.
-
-
-
-
- Parameter(s):
-
-
-
-
- cb
-
-
- The circular_buffer_space_optimized whose content will be swapped.
-
-
-
-
-
-
- Throws:
-
-
- Nothing.
-
-
-
-
- Exception Safety:
-
-
- No-throw.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators of both circular_buffer_space_optimized containers. (On the
- other hand the iterators still point to the same elements but within another container. If you want to
- rely on this feature you have to turn the Debug Support off
- otherwise an assertion will report an error if such invalidated iterator is used.)
-
-
-
-
- Complexity:
-
-
- Constant (in the size of the circular_buffer_space_optimized).
-
- void
- push_back(const_reference
- item = value_type());
-
- Insert a new element at the end of the space optimized circular buffer.
-
-
- Effect:
-
-
- if capacity().capacity()
- > 0 then back() ==
- item
- If the circular_buffer_space_optimized is full, the first element will be removed. If the
- capacity is 0, nothing will be inserted.
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- void
- push_front(const_reference
- item = value_type());
-
- Insert a new element at the beginning of the space optimized circular buffer.
-
-
- Effect:
-
-
- if capacity().capacity()
- > 0 then front() ==
- item
- If the circular_buffer_space_optimized is full, the last element will be removed. If the
- capacity is 0, nothing will be inserted.
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- void
- pop_back();
-
- Remove the last element from the space optimized circular buffer.
-
-
- Precondition:
-
-
- !empty()
-
-
-
-
- Effect:
-
-
- The last element is removed from the circular_buffer_space_optimized.
-
- The amount of allocated memory in the internal buffer may be predictively decreased.
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- void
- pop_front();
-
- Remove the first element from the space optimized circular buffer.
-
-
- Precondition:
-
-
- !empty()
-
-
-
-
- Effect:
-
-
- The first element is removed from the circular_buffer_space_optimized.
-
- The amount of allocated memory in the internal buffer may be predictively decreased.
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- iterator
- insert(iterator pos,
- const_reference
- item = value_type());
-
- Insert an element at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
-
-
-
-
- Effect:
-
-
- The item will be inserted at the position pos.
- If the circular_buffer_space_optimized is full, the first element will be overwritten. If
- the circular_buffer_space_optimized is full and the pos points to
- begin(),
- then the item will not be inserted. If the capacity is 0, nothing will be
- inserted.
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the item will be inserted.
-
-
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the inserted element or begin()
- if the item is not inserted. (See the Effect.)
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- void
- insert(iterator pos,
- size_type n,
- const_reference
- item);
-
- Insert n copies of the item at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
-
-
-
-
- Effect:
-
-
- The number of min[n, (pos - begin()) +
- reserve()]
- elements will be inserted at the position pos.
- The number of min[pos - begin(),
- max[0, n - reserve()]]
- elements will be overwritten at the beginning of the circular_buffer_space_optimized.
- (See Example for the explanation.)
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the items will be inserted.
-
-
-
-
-
-
- n
-
-
- The number of items the to be inserted.
-
-
-
-
-
-
- item
-
-
- The element whose copies will be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
- Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its
- internal buffer may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting 5 elements at the position p:
-
- insert(p, (size_t)5, 0);
-
- actually only 4 elements get inserted and elements 1 and 2 are overwritten.
- This is due to the fact the insert operation preserves the capacity. After insertion the internal
- buffer looks like this:
-
- |0|0|0|0|3|4|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|0|0|0|0|0|3|4|.
-
- template
- <class InputIterator>
- void insert(iterator pos,
- InputIterator first, InputIterator last);
-
- Insert the range [first, last) at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
- Valid range [first, last) where first and last meet the
- requirements of an InputIterator.
-
-
-
-
- Effect:
-
-
- Elements from the range [first + max[0, distance(first, last) - (pos - begin()) -
- reserve()],
- last) will be inserted at the position pos.
- The number of min[pos - begin(),
- max[0, distance(first, last) - reserve()]]
- elements will be overwritten at the beginning of the circular_buffer_space_optimized.
- (See Example for the explanation.)
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the range will be inserted.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be inserted.
-
-
-
-
-
-
- last
-
-
- The end of the range to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in [size() +
- std::distance(first, last)]; in min[capacity().capacity(),
- size() +
- std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its
- internal buffer may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting a range of elements at the position p:
-
- int array[] = { 5, 6, 7, 8, 9 };
- insert(p, array, array + 5);
-
- actually only elements 6, 7, 8 and 9 from the
- specified range get inserted and elements 1 and 2 are overwritten. This is
- due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks
- like this:
-
- |6|7|8|9|3|4|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|5|6|7|8|9|3|4|.
-
- iterator
- rinsert(iterator pos,
- const_reference
- item = value_type());
-
- Insert an element before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
-
-
-
-
- Effect:
-
-
- The item will be inserted before the position pos.
- If the circular_buffer_space_optimized is full, the last element will be overwritten. If
- the circular_buffer_space_optimized is full and the pos points to
- end(),
- then the item will not be inserted. If the capacity is 0, nothing will be
- inserted.
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position before which the item will be inserted.
-
-
-
-
-
-
- item
-
-
- The element to be inserted.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the inserted element or end()
- if the item is not inserted. (See the Effect.)
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- void
- rinsert(iterator pos,
- size_type n,
- const_reference
- item);
-
- Insert n copies of the item before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
-
-
-
-
- Effect:
-
-
- The number of min[n, (end() -
- pos) + reserve()]
- elements will be inserted before the position pos.
- The number of min[end() -
- pos, max[0, n - reserve()]]
- elements will be overwritten at the end of the circular_buffer_space_optimized.
- (See Example for the explanation.)
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the items will be inserted.
-
-
-
-
-
-
- n
-
-
- The number of items the to be inserted.
-
-
-
-
-
-
- item
-
-
- The element whose copies will be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
- Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its
- internal buffer may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting 5 elements before the position p:
-
- rinsert(p, (size_t)5, 0);
-
- actually only 4 elements get inserted and elements 3 and 4 are overwritten.
- This is due to the fact the rinsert operation preserves the capacity. After insertion the internal
- buffer looks like this:
-
- |1|2|0|0|0|0|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|0|0|0|0|0|3|4|.
-
- template
- <class InputIterator>
- void rinsert(iterator pos,
- InputIterator first, InputIterator last);
-
- Insert the range [first, last) before the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized or
- its end.
- Valid range [first, last) where first and last meet the
- requirements of an InputIterator.
-
-
-
-
- Effect:
-
-
- Elements from the range [first, last - max[0, distance(first, last) - (end() -
- pos) - reserve()])
- will be inserted before the position pos.
- The number of min[end() -
- pos, max[0, distance(first, last) - reserve()]]
- elements will be overwritten at the end of the circular_buffer.
- (See Example for the explanation.)
-
- The amount of allocated memory in the internal buffer may be predictively increased.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator specifying the position where the range will be inserted.
-
-
-
-
-
-
- first
-
-
- The beginning of the range to be inserted.
-
-
-
-
-
-
- last
-
-
- The end of the range to be inserted.
-
-
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::T(const T&) throws.
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in [size() +
- std::distance(first, last)]; in min[capacity().capacity(),
- size() +
- std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
-
-
-
-
- Example:
-
-
- Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its
- internal buffer may look like the one below.
-
- |1|2|3|4| | |
- p ---^
-
- After inserting a range of elements before the position p:
-
- int array[] = { 5, 6, 7, 8, 9 };
- insert(p, array, array + 5);
-
- actually only elements 5, 6, 7 and 8 from the
- specified range get inserted and elements 3 and 4 are overwritten. This is
- due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks
- like this:
-
- |1|2|5|6|7|8|
-
- For comparison if the capacity would not be preserved the internal buffer would then result in
- |1|2|5|6|7|8|9|3|4|.
-
- The elements from the range [first, last) are removed. (If first == last
- nothing is removed.)
-
- The amount of allocated memory in the internal buffer may be predictively decreased.
-
-
-
-
- Parameter(s):
-
-
-
-
- first
-
-
- The beginning of the range to be removed.
-
-
-
-
-
-
- last
-
-
- The end of the range to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining beyond the removed elements or end()
- if no such element exists.
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- iterator
- rerase(iterator
- pos);
-
- Remove an element at the specified position.
-
-
- Precondition:
-
-
- pos is a valid iterator pointing to the circular_buffer_space_optimized (but
- not an end()).
-
-
- The amount of allocated memory in the internal buffer may be predictively decreased.
-
-
-
-
- Effect:
-
-
- The element at the position pos is removed.
-
-
-
-
- Parameter(s):
-
-
-
-
- pos
-
-
- An iterator pointing at the element to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining in front of the removed element or begin()
- if no such element exists.
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- The elements from the range [first, last) are removed. (If first == last
- nothing is removed.)
-
- The amount of allocated memory in the internal buffer may be predictively decreased.
-
-
-
-
- Parameter(s):
-
-
-
-
- first
-
-
- The beginning of the range to be removed.
-
-
-
-
-
-
- last
-
-
- The end of the range to be removed.
-
-
-
-
-
-
- Returns:
-
-
- Iterator to the first element remaining in front of the removed elements or begin()
- if no such element exists.
-
-
-
-
- Throws:
-
-
- An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is
- used).
-
-
- Whatever T::operator = (const T&) throws.
-
-
-
-
- Exception Safety:
-
-
- Basic.
-
-
-
-
- Iterator Invalidation:
-
-
- Invalidates all iterators pointing to the circular_buffer_space_optimized (except
- iterators equal to end()).
-
-
-
-
- Complexity:
-
-
- Linear (in the size of the circular_buffer_space_optimized).
-
- Use, modification, and distribution is subject to the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
- Use, modification, and distribution is subject to the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-