From ee98eb933aea21879fa1bdff361a726deba39b89 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41369] --- doc/Doxyfile | 227 - doc/HOWTO-srcdoc | 52 - doc/Tidy.conf | 18 - doc/circular_buffer.html | 6788 --------------------------- doc/circular_buffer.png | Bin 21147 -> 0 bytes doc/circular_buffer.xslt | 68 - doc/copy.xslt | 20 - doc/doxygen2html.xslt | 363 -- doc/html2xhtml.xslt | 18 - doc/space_optimized.html | 4171 ---------------- doc/space_optimized.png | Bin 25514 -> 0 bytes doc/space_optimized.xslt | 106 - doc/update_srcdoc.sh | 54 - doc/update_srcdoc.xslt | 25 - doc/valid-html40.png | Bin 1444 -> 0 bytes index.html | 22 - test/Jamfile.v2 | 17 - test/base_test.cpp | 704 --- test/bounded_buffer_comparison.cpp | 288 -- test/common.ipp | 1827 ------- test/soft_iterator_invalidation.cpp | 747 --- test/space_optimized_test.cpp | 191 - test/test.hpp | 146 - 23 files changed, 15852 deletions(-) delete mode 100644 doc/Doxyfile delete mode 100644 doc/HOWTO-srcdoc delete mode 100644 doc/Tidy.conf delete mode 100644 doc/circular_buffer.html delete mode 100644 doc/circular_buffer.png delete mode 100644 doc/circular_buffer.xslt delete mode 100644 doc/copy.xslt delete mode 100644 doc/doxygen2html.xslt delete mode 100644 doc/html2xhtml.xslt delete mode 100644 doc/space_optimized.html delete mode 100644 doc/space_optimized.png delete mode 100644 doc/space_optimized.xslt delete mode 100644 doc/update_srcdoc.sh delete mode 100644 doc/update_srcdoc.xslt delete mode 100644 doc/valid-html40.png delete mode 100644 index.html delete mode 100644 test/Jamfile.v2 delete mode 100644 test/base_test.cpp delete mode 100644 test/bounded_buffer_comparison.cpp delete mode 100644 test/common.ipp delete mode 100644 test/soft_iterator_invalidation.cpp delete mode 100644 test/space_optimized_test.cpp delete mode 100644 test/test.hpp 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 @@ - - - - - - Templated Circular Buffer Container - - - - - - - - - -
-

- Templated Circular Buffer Container -

-

- circular_buffer<T, Alloc> -

-
- Boost -
-

- Contents -

Description
- Introductory Example
- Synopsis
- Rationale
- Caveats
- Debug Support
- More Examples
- Header Files
- Modelled Concepts
- Template Parameters
- Public Types
- Constructors and Destructor
- Public Member Functions
- Standalone Functions
- Notes
- See also
- Acknowledgements - - - - - - - -
- Circular Buffer -
- - - - - -
- Figure: - - The circular buffer (for someone known as ring or cyclic buffer). -
-
-

- Description -

-

- 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. -

-

- Introductory Example -

-

- A brief example using the circular_buffer: -

-
-   #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;
-   }
-
-

- Synopsis -

-
- - - - -
-
-namespace boost {
-
-template <class T, class Alloc>
-class circular_buffer
-{
-public:
-   typedef typename Alloc::value_type value_type;
-   typedef typename Alloc::pointer pointer;
-   typedef typename Alloc::const_pointer const_pointer;
-   typedef typename Alloc::reference reference;
-   typedef typename Alloc::const_reference const_reference;
-   typedef typename Alloc::difference_type difference_type;
-   typedef typename Alloc::size_type size_type;
-   typedef Alloc allocator_type;
-   typedef implementation-defined const_iterator;
-   typedef implementation-defined iterator;
-   typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
-   typedef boost::reverse_iterator<iterator> reverse_iterator;
-   typedef std::pair<pointer, size_type> array_range;
-   typedef std::pair<const_pointer, size_type> const_array_range;
-   typedef size_type capacity_type;
-
-   explicit circular_buffer(const allocator_type& alloc = allocator_type());
-   explicit circular_buffer(capacity_type capacity, const allocator_type& alloc = allocator_type());
-   circular_buffer(size_type n, const_reference item, const allocator_type& alloc = allocator_type());
-   circular_buffer(capacity_type capacity, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
-   circular_buffer(const circular_buffer<T, Alloc>& cb);
-   template <class InputIterator>
-      circular_buffer(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
-   template <class InputIterator>
-      circular_buffer(capacity_type capacity, InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
-   ~circular_buffer();
-
-   allocator_type get_allocator() const;
-   allocator_type& get_allocator();
-   iterator begin();
-   iterator end();
-   const_iterator begin() const;
-   const_iterator end() const;
-   reverse_iterator rbegin();
-   reverse_iterator rend();
-   const_reverse_iterator rbegin() const;
-   const_reverse_iterator rend() const;
-   reference operator[](size_type index);
-   const_reference operator[](size_type index) const;
-   reference at(size_type index);
-   const_reference at(size_type index) const;
-   reference front();
-   reference back();
-   const_reference front() const;
-   const_reference back() const;
-   array_range array_one();
-   array_range array_two();
-   const_array_range array_one() const;
-   const_array_range array_two() const;
-   pointer linearize();
-   size_type size() const;
-   size_type max_size() const;
-   bool empty() const;
-   bool full() const;
-   size_type reserve() const;
-   capacity_type capacity() const;
-   void set_capacity(capacity_type new_capacity);
-   void resize(size_type new_size, const_reference item = value_type());
-   void rset_capacity(capacity_type new_capacity);
-   void rresize(size_type new_size, const_reference item = value_type());
-   circular_buffer<T, Alloc>& operator=(const circular_buffer<T, Alloc>& cb);
-   void assign(size_type n, const_reference item);
-   void assign(capacity_type capacity, size_type n, const_reference item);
-   template <class InputIterator>
-      void assign(InputIterator first, InputIterator last);
-   template <class InputIterator>
-      void assign(capacity_type capacity, InputIterator first, InputIterator last);
-   void swap(circular_buffer<T, Alloc>& cb);
-   void push_back(const_reference item = value_type());
-   void push_front(const_reference item = value_type());
-   void pop_back();
-   void pop_front();
-   iterator insert(iterator pos, const_reference item = value_type());
-   void insert(iterator pos, size_type n, const_reference item);
-   template <class InputIterator>
-      void insert(iterator pos, InputIterator first, InputIterator last);
-   iterator rinsert(iterator pos, const_reference item = value_type());
-   void rinsert(iterator pos, size_type n, const_reference item);
-   template <class InputIterator>
-      void rinsert(iterator pos, InputIterator first, InputIterator last);
-   iterator erase(iterator pos);
-   iterator erase(iterator first, iterator last);
-   iterator rerase(iterator pos);
-   iterator rerase(iterator first, iterator last);
-   void clear();
-};
-
-template <class T, class Alloc>
-   bool operator==(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator<(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator!=(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator<=(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator>=(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
-template <class T, class Alloc>
-   void swap(circular_buffer<T, Alloc>& lhs, circular_buffer<T, Alloc>& rhs);
-
-} // namespace boost
-
-
-
-

- Rationale -

-

- 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: -

-
    -
  1. Maximum efficiency for envisaged applications. -
  2. -
  3. Suitable for general purpose use. -
  4. -
  5. The behaviour of the buffer as intuitive as possible. -
  6. -
  7. Suitable for specialization by means of adaptors. (The circular_buffer_space_optimized is such an example of the adaptor.) -
  8. -
  9. Easy to debug. (See Debug Support for details.) -
  10. -
-

- In order to achieve maximum efficiency, the circular_buffer stores its elements in a contiguous - region of memory, which then enables: -

-
    -
  1. Use of fixed memory and no implicit or unexpected memory allocation. -
  2. -
  3. Fast constant-time insertion and removal of elements from the front and back. -
  4. -
  5. Fast constant-time random access of elements. -
  6. -
  7. Suitability for real-time and performance critical applications. -
  8. -
-

- Possible applications of the circular_buffer include: -

- -

- The following paragraphs describe issues that had to be considered during the implementation of the - circular_buffer: -

-

- Thread-Safety -

-

- 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: -

-
    -
  1. Inform the data source to wait until there is room in the buffer (e.g. by throwing an overflow exception). -
  2. -
  3. If the oldest data is the most important, ignore new data from the source until there is room in the buffer - again. -
  4. -
  5. If the latest data is the most important, write over the oldest data. -
  6. -
  7. Let the producer to be responsible for checking the size of the buffer prior writing into it. -
  8. -
-

- 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: -

-
    -
  1. It would introduce performance overhead. -
  2. -
  3. No other std container implements it this way. -
  4. -
-

- 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. -

-

- Caveats -

-

- 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. -

-

- Debug Support -

-

- 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. -

-

- More Examples -

-

- 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. -

-

- Bounded Buffer Example -

-

- 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. -

-
-   #include <boost/circular_buffer.hpp>
-   #include <boost/thread/mutex.hpp>
-   #include <boost/thread/condition.hpp>
-   #include <boost/thread/thread.hpp>
-   #include <boost/progress.hpp>
-   #include <boost/bind.hpp>
-
-   template <class T>
-   class bounded_buffer {
-   public:
-
-      typedef boost::circular_buffer<T> container_type;
-      typedef typename container_type::size_type size_type;
-      typedef typename container_type::value_type value_type;
-
-      explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
-
-      void push_front(const value_type& item) {
-         boost::mutex::scoped_lock lock(m_mutex);
-         m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
-         m_container.push_front(item);
-         ++m_unread;
-         lock.unlock();
-         m_not_empty.notify_one();
-      }
-
-      void pop_back(value_type* pItem) {
-         boost::mutex::scoped_lock lock(m_mutex);
-         m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
-         *pItem = m_container[--m_unread];
-         lock.unlock();
-         m_not_full.notify_one();
-      }
-
-   private:
-      bounded_buffer(const bounded_buffer&);              // Disabled copy constructor
-      bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator
-
-      bool is_not_empty() const { return m_unread > 0; }
-      bool is_not_full() const { return m_unread < m_container.capacity(); }
-
-      size_type m_unread;
-      container_type m_container;
-      boost::mutex m_mutex;
-      boost::condition m_not_empty;
-      boost::condition m_not_full;
-   };
-
-

- The bounded_buffer uses Boost Threads and Boost Bind libraries. -

-

- 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.) -

-

- Header Files -

-

- The circular_buffer is defined in the file boost/circular_buffer.hpp. There is also a forward declaration - for the circular_buffer in the header file boost/circular_buffer_fwd.hpp. -

-

- Modelled Concepts -

-

- Random Access Container, Front Insertion Sequence and Back Insertion Sequence. -

-

- Template Parameters -

-
- - - - - - -
- Parameter - - Description - - Default -
-
-

- Public Types -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Type - - Description -
- value_type - - The type of elements stored in the circular_buffer. -
- pointer - - A pointer to an element. -
- const_pointer - - A const pointer to the element. -
- reference - - A reference to an element. -
- const_reference - - A const reference to an element. -
- difference_type - - The distance type. (A signed integral type used to represent the distance between two iterators.) -
- size_type - - The size type. (An unsigned integral type that can represent any non-negative value of the container's - distance type.) -
- allocator_type - - The type of an allocator used in the circular_buffer. -
- const_iterator - - A const (random access) iterator used to iterate through the circular_buffer. -
- iterator - - A (random access) iterator used to iterate through the circular_buffer. -
- const_reverse_iterator - - A const iterator used to iterate backwards through a circular_buffer. -
- reverse_iterator - - An iterator used to iterate backwards through a circular_buffer. -
- array_range - - 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.) -
- const_array_range - - 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.) -
- capacity_type - - The capacity type. (Same as size_type - defined for consistency with the circular_buffer_space_optimized.) -
-
-

- Constructors and Destructor -

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- explicit - circular_buffer(const allocator_type& alloc = - allocator_type());
-
- Create an empty circular_buffer with a maximum capacity. -
-
- Effect: -
-
- capacity() == - max_size() && - size() == 0 -
-
-
-
- Parameter(s): -
-
-
-
- alloc -
-
- The allocator. -
-
-
-
-
-
- Throws: -
-
- 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. -
-
- Effect: -
-
- capacity() == - capacity && size() == 0 -
-
-
-
- Parameter(s): -
-
-
-
- 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. -
-
- Effect: -
-
- capacity() == n - && full() - && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == - item -
-
-
-
- Parameter(s): -
-
-
-
- n -
-
- 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. -
-
- Precondition: -
-
- capacity >= n -
-
-
-
- Effect: -
-
- capacity() == - capacity && size() == n && - (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == - item -
-
-
-
- Parameter(s): -
-
-
-
- capacity -
-
- The capacity of the created circular_buffer. -
-
-
-
-
-
- n -
-
- 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(const - circular_buffer<T,Alloc>& cb);
-
- The copy constructor. -

- 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. -
-
-
-
- Effect: -
-
- capacity() == - std::distance(first, last) && full() && (*this)[0]== - *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, - last) - 1] == *(last - 1) -
-
-
-
- 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(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()). -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- clear() -
-
-
-
-

- Public Member Functions -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- allocator_type get_allocator() - const;
-
- Get the allocator. -
-
- Returns: -
-
- The allocator. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- get_allocator() for - obtaining an allocator reference. -
-
-
- allocator_type& - get_allocator();
-
- Get the allocator reference. -
-
- Returns: -
-
- A reference to the allocator. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- Note: -
-
- This method was added in order to optimize obtaining of the allocator with a state, although use of - stateful allocators in STL is discouraged. -
-
-
-
- See Also: -
-
- get_allocator() - const -
-
-
- 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). -
-
-
-
- See Also: -
-
- end(), - rbegin(), - rend() -
-
-
- 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). -
-
-
-
- See Also: -
-
- begin(), - rbegin(), - rend() -
-
-
- 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). -
-
-
-
- See Also: -
-
- end() - const, rbegin() const, - rend() - const -
-
-
- 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). -
-
-
-
- See Also: -
-
- begin() - const, rbegin() const, - rend() - const -
-
-
- 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). -
-
-
-
- See Also: -
-
- rend(), - begin(), - end() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rbegin(), - begin(), - end() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rend() - const, begin() const, - end() - const -
-
-
- 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). -
-
-
-
- See Also: -
-
- rbegin() - const, begin() const, - end() - const -
-
-
- reference operator[](size_type index);
-
- Get the element at the index position. -
-
- Precondition: -
-
- 0 <= index && index < size() -
-
-
-
- Parameter(s): -
-
-
-
- index -
-
- The position of the element. -
-
-
-
-
-
- Returns: -
-
- A reference to the element at the index position. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- at() -
-
-
- const_reference operator[](size_type index) - const;
-
- Get the element at the index position. -
-
- Precondition: -
-
- 0 <= index && index < size() -
-
-
-
- Parameter(s): -
-
-
-
- index -
-
- The position of the element. -
-
-
-
-
-
- Returns: -
-
- A const reference to the element at the index position. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- at() const -
-
-
- reference at(size_type index);
-
- Get the element at the index position. -
-
- Parameter(s): -
-
-
-
- index -
-
- The position of the element. -
-
-
-
-
-
- Returns: -
-
- A reference to the element at the index position. -
-
-
-
- Throws: -
-
- std::out_of_range when the index is invalid (when index >= size()). -
-
-
-
- Exception Safety: -
-
- Strong. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- operator[] -
-
-
- const_reference at(size_type index) - const;
-
- Get the element at the index position. -
-
- Parameter(s): -
-
-
-
- index -
-
- The position of the element. -
-
-
-
-
-
- Returns: -
-
- A const reference to the element at the index position. -
-
-
-
- Throws: -
-
- std::out_of_range when the index is invalid (when index >= size()). -
-
-
-
- Exception Safety: -
-
- Strong. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- operator[] - const -
-
-
- reference front();
-
- Get the first element. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Returns: -
-
- A reference to the first element of 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). -
-
-
-
- See Also: -
-
- back() -
-
-
- reference back();
-
- Get the last element. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Returns: -
-
- A reference to the last element of 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). -
-
-
-
- See Also: -
-
- front() -
-
-
- const_reference front() - const;
-
- Get the first element. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Returns: -
-
- A const reference to the first element of 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). -
-
-
-
- See Also: -
-
- back() - const -
-
-
- const_reference back() - const;
-
- Get the last element. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Returns: -
-
- A const reference to the last element of 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). -
-
-
-
- See Also: -
-
- front() - const -
-
-
- 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). -
-
-
-
- See Also: -
-
- array_two(), - linearize() -
-
-
- 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). -
-
-
-
- See Also: -
-
- array_one() -
-
-
- 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). -
-
-
-
- See Also: -
-
- array_two() - const; array_one() for more - details how to pass data into a legacy C API. -
-
-
- 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). -
-
-
-
- See Also: -
-
- array_one() - const -
-
-
- pointer linearize();
-
- Linearize the internal buffer into a continuous array. -

- This method can be useful when passing the stored data into a legacy C API as an array. -

-
-
- Effect: -
-
- &(*this)[0] < &(*this)[1] < ... < &(*this)[size() - 1] -
-
-
-
- Returns: -
-
- 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). -
-
-
-
- See Also: -
-
- capacity(), - max_size(), - reserve(), - resize() -
-
-
- size_type max_size() - const;
-
- Get the largest possible size or capacity of the circular_buffer. -
-
- Returns: -
-
- The maximum size/capacity the circular_buffer can be set to. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- size(), - capacity(), - reserve() -
-
-
- bool empty() - const;
-
- Is the circular_buffer empty? -
-
- Returns: -
-
- true if there are no elements stored in the circular_buffer; - false otherwise. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- full() -
-
-
- bool full() - const;
-
- Is the circular_buffer full? -
-
- Returns: -
-
- true if the number of elements stored in the circular_buffer equals the - capacity of the circular_buffer; false otherwise. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- empty() -
-
-
- 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. -
-
- Returns: -
-
- capacity() - - size() -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- capacity(), - size(), - max_size() -
-
-
- capacity_type capacity() - const;
-
- Get the capacity of the circular_buffer. -
-
- Returns: -
-
- The maximum number of elements which can be 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). -
-
-
-
- See Also: -
-
- reserve(), - size(), - max_size(), - set_capacity() -
-
-
- 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. -
-
-
-
- Complexity: -
-
- Linear (in min[size(), new_capacity]). -
-
-
-
- See Also: -
-
- rset_capacity(), - resize() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rresize(), - set_capacity() -
-
-
- 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. -
-
-
-
- Complexity: -
-
- Linear (in min[size(), new_capacity]). -
-
-
-
- See Also: -
-
- set_capacity(), - rresize() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rresize(), - set_capacity() -
-
-
- circular_buffer<T,Alloc>& - operator=(const circular_buffer<T,Alloc>& cb);
-
- The assign operator. -

- Makes this circular_buffer to become 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. -
-
-
-
- Exception Safety: -
-
- Strong. -
-
-
-
- Iterator Invalidation: -
-
- Invalidates all iterators pointing to this circular_buffer (except iterators equal to - end()). -
-
-
-
- Complexity: -
-
- Linear (in the size of cb). -
-
-
-
- See Also: -
-
- assign(size_type, - const_reference), assign(capacity_type, size_type, - const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- void assign(size_type n, const_reference - item);
-
- Assign n items into the circular_buffer. -

- The content of the circular_buffer will be removed and replaced with n copies - of the item. -

-
-
- Effect: -
-
- capacity() == n - && size() == n - && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] - == item -
-
-
-
- Parameter(s): -
-
-
-
- n -
-
- The number of elements the circular_buffer will be filled with. -
-
-
-
-
-
- item -
-
- The element the circular_buffer 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 (except iterators equal to - end()). -
-
-
-
- Complexity: -
-
- Linear (in the n). -
-
-
-
- See Also: -
-
- operator=, - assign(capacity_type, - size_type, const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- void assign(capacity_type capacity, size_type n, const_reference - item);
-
- Assign n items 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 n copies of the - item. -

-
-
- Precondition: -
-
- capacity >= n -
-
-
-
- Effect: -
-
- capacity() == - capacity && size() == n && - (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == - item -
-
-
-
- Parameter(s): -
-
-
-
- capacity -
-
- The new capacity. -
-
-
-
-
-
- n -
-
- The number of elements the circular_buffer will be filled with. -
-
-
-
-
-
- item -
-
- The element the circular_buffer 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 (except iterators equal to - end()). -
-
-
-
- Complexity: -
-
- Linear (in the n). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- template <class - InputIterator>
- void assign(InputIterator first, InputIterator last);

-
- Assign a copy of the range into the circular_buffer. -

- 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() == - std::distance(first, last) && size() == std::distance(first, - last) && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && - (*this)[std::distance(first, last) - 1] == *(last - 1) -
-
-
-
- Parameter(s): -
-
-
-
- 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 the std::distance(first, last)). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(capacity_type, size_type, - const_reference), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- 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). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(capacity_type, size_type, - const_reference), assign(InputIterator, - InputIterator) -
-
-
- 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). -
-
-
-
- See Also: -
-
- swap(circular_buffer<T, - Alloc>&, circular_buffer<T, Alloc>&) -
-
-
- 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). -
-
-
-
- See Also: -
-
- push_front(), - pop_back(), - pop_front() -
-
-
- 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). -
-
-
-
- See Also: -
-
- push_back(), - pop_back(), - pop_front() -
-
-
- void - pop_back();
-
- Remove the last element from the circular_buffer. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Effect: -
-
- The last element is removed from the circular_buffer. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Invalidates only iterators pointing to the removed element. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- pop_front(), - push_back(), - push_front() -
-
-
- void - pop_front();
-
- Remove the first element from the circular_buffer. -
-
- Precondition: -
-
- !empty() -
-
-
-
- Effect: -
-
- The first element is removed from the circular_buffer. -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Invalidates only iterators pointing to the removed element. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- pop_back(), - push_back(), - push_front() -
-
-
- 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 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. -
-
-
-
- Complexity: -
-
- Linear (in std::distance(pos, end())). -
-
-
-
- See Also: -
-
- insert(iterator, - size_type, value_type), insert(iterator, InputIterator, - InputIterator), rinsert(iterator, - value_type), rinsert(iterator, size_type, - value_type), rinsert(iterator, InputIterator, - InputIterator) -
-
-
- 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 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|. -
-
-
-
- See Also: -
-
- insert(iterator, - value_type), insert(iterator, InputIterator, - InputIterator), rinsert(iterator, - value_type), rinsert(iterator, size_type, - value_type), rinsert(iterator, InputIterator, - InputIterator) -
-
-
- 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|. -
-
-
-
- See Also: -
-
- insert(iterator, - value_type), insert(iterator, size_type, - value_type), rinsert(iterator, - value_type), rinsert(iterator, size_type, - value_type), rinsert(iterator, InputIterator, - InputIterator) -
-
-
- 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. -
-
-
-
- Complexity: -
-
- Linear (in std::distance(begin(), pos)). -
-
-
-
- See Also: -
-
- rinsert(iterator, - size_type, value_type), rinsert(iterator, InputIterator, - InputIterator), insert(iterator, - value_type), insert(iterator, size_type, - value_type), insert(iterator, InputIterator, - InputIterator) -
-
-
- 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|. -
-
-
-
- See Also: -
-
- rinsert(iterator, - value_type), rinsert(iterator, InputIterator, - InputIterator), insert(iterator, - value_type), insert(iterator, size_type, - value_type), insert(iterator, InputIterator, - InputIterator) -
-
-
- 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|. -
-
-
-
- See Also: -
-
- rinsert(iterator, - value_type), rinsert(iterator, size_type, - value_type), insert(iterator, - value_type), insert(iterator, size_type, - value_type), insert(iterator, InputIterator, - InputIterator) -
-
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in std::distance(pos, end())). -
-
-
-
- See Also: -
-
- erase(iterator, - iterator), rerase(iterator), - rerase(iterator, - iterator), clear() -
-
-
- iterator erase(iterator first, iterator last);
-
- Erase the range [first, last). -
-
- Precondition: -
-
- Valid range [first, last). -
-
-
-
- Effect: -
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in std::distance(first, end())). -
-
-
-
- See Also: -
-
- erase(iterator), - rerase(iterator), - rerase(iterator, - iterator), clear() -
-
-
- 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). -
-
-
-
- Complexity: -
-
- Linear (in std::distance(begin(), pos)). -
-
-
-
- See Also: -
-
- erase(iterator), - erase(iterator, - iterator), rerase(iterator, - iterator), clear() -
-
-
- iterator rerase(iterator first, iterator last);
-
- Erase the range [first, last). -
-
- Precondition: -
-
- Valid range [first, last). -
-
-
-
- Effect: -
-
- 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). -
-
-
-
- Complexity: -
-
- Linear (in std::distance(begin(), last)). -
-
-
-
- See Also: -
-
- erase(iterator), - erase(iterator, - iterator), rerase(iterator), - clear() -
-
-
- void - clear();
-
- Remove all stored elements from the circular_buffer. -
-
- Effect: -
-
- size() == - 0 -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Invalidates all iterators pointing to the circular_buffer (except iterators equal to - end()). -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffer). -
-
-
-
- See Also: -
-
- ~circular_buffer(), - erase(iterator), - erase(iterator, - iterator), rerase(iterator), - rerase(iterator, - iterator) -
-
-
-
-

- Standalone Functions -

-
- - - - - - - - - - - - - - - - - - - - - - -
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- lhs.size() == - rhs.size() && - std::equal(lhs.begin(), lhs.end(), rhs.begin()) -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- std::lexicographical_compare(lhs.begin(), - lhs.end(), rhs.begin(), rhs.end()) -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- !(lhs == rhs) -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- See Also: -
-
- operator==(const - circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&) -
-
-
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- rhs < lhs -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- See Also: -
-
- operator<(const - circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&) -
-
-
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- !(rhs < lhs) -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- See Also: -
-
- operator<(const - circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&) -
-
-
- 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. -
-
- Parameter(s): -
-
-
-
- lhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- rhs -
-
- The circular_buffer to compare. -
-
-
-
-
-
- Returns: -
-
- !(lhs < rhs) -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Complexity: -
-
- Linear (in the size of the circular_buffers). -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- See Also: -
-
- operator<(const - circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&) -
-
-
- 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.) -
-
-
-
- See Also: -
-
- swap(circular_buffer<T, - Alloc>&) -
-
-
-
-

- Notes -

-
    -
  1. - -

    - A good implementation of smart pointers is included in Boost. -

    -
  2. -
  3. - -

    - 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.) -

    -
  4. -
-

- See also -

-

- boost::circular_buffer_space_optimized, std::vector, std::list, std::deque -

-

- Acknowledgements -

-

- 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. -

-
- - - - - - - - diff --git a/doc/circular_buffer.png b/doc/circular_buffer.png deleted file mode 100644 index 1370a4b51bbc378bb28a6b9c824ca922afb3160c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21147 zcmeAS@N?(olHy`uVBq!ia0y~yVANq?VD#Z&VqjqS_gbuifq{V~-O<;Pfg$4fANL0! zVTELmAYTTCDpdxChGqtapZ^&c8lEvQlTJv61Q8ws9D)kF(hjln z%lXVQ>0Ges_xJbv>;KQoiSD?<7wFvSx;Q~3fR%woU~l%JuC6ZEZn1}f7p`7Cdf>o@ z>hF1*)^hOjvPw0@pUpF1FbZpAyjj-U6zE{dz@bo;ekl9;x~ET{*8cw|+b_jstmw#K zB4at7>88onJdqxzKMV>DYzzD=K0P_PVS|AUSH>*P#<%|A;o&BZ3r=M0E)n4oVc=N6 zc%o&0{eL|zEvv#uEPAX5d^pz3ZCLB&=y-6`CZmo7aR~`2DW&kF%?B73Nq9Kj=<4d4 zV8fHh96dWTGt+@>LJP;Cvn|XEI0E#)?zQ4_V-y5gnpX1V@$vqhJ9kdkk3XixeX_;j z*w4?;8-EH++N$vL)xW>LKU4{MFnv~W@s^S}u=TKZ(2hWXUI*sJsd8y`%&QKrk#j$& zv49`sxY>(-{Q0?g`*!m%%_lJ|XQB>7@kR8P9%Qf)S9~s$Viu+5lAN6T+Udy3SNj7E zxH?!F7)>T<=F3SWbSXa<_IP(_mUBZ^!&j9h`s`;`e@J_kp(exX%+0`ZfnoWcCr_Tp zT9+;0T$JjRz{Z?r_N0>~VYQGRH;aSj6R~H=DkrP^i;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!YL%LTANLIXG-9tt$zVv~TnZ82$r4U7z$Jonp9 U%bmK;z`(%Z>FVdQ&MBb@01 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/copy.xslt b/doc/copy.xslt deleted file mode 100644 index 95f5f10..0000000 --- a/doc/copy.xslt +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - diff --git a/doc/doxygen2html.xslt b/doc/doxygen2html.xslt deleted file mode 100644 index c7e7a50..0000000 --- a/doc/doxygen2html.xslt +++ /dev/null @@ -1,363 +0,0 @@ - - - - - -]> - - - - - - - - - - - -
Source Code Documentation
- - - - - -
- - -   - - - - - - - - - - - -
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - -
-
-
-
-
- - - - - - - - -
-
- - - -
- - -
Returns:
-
- - -
Precondition:
-
- - -
Effect:
-
- - -
:
-
- - -
Warning:
-
- - -
Note:
-
- - -
See Also:
-
- - -
- -
-
- - -
- - -
-
- - - - - - - - -
- - -
-
-namespace boost {
-
-template <>
-class 
-{
-public:
-
-
-
-
-};
-
-
-
-} // namespace boost
-
-
-
-
- - - -   - - - - -    typedef  - - implementation-defined  -   - - ; - - - - - - - - - - - template < > -    - -   - - - ( -   - - - ); - - - - - - - - const_reference - - - - - - - -   - - - - - - -
- - - -
ParameterDescriptionDefault
-
-
- - - -
TypeDescription
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- - - - - - - -
Type Requirements:
-
-
- - - - - - -
-
- -
- - - - - - - - - - - - - - - - - - template < >
    -
-   - ( -   - - - );


- - -

-
-

- -
- - - - - - - - - - const_reference - - - const_reference - - - - - - - - - - - - -   - - - -
diff --git a/doc/html2xhtml.xslt b/doc/html2xhtml.xslt deleted file mode 100644 index bddb627..0000000 --- a/doc/html2xhtml.xslt +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/doc/space_optimized.html b/doc/space_optimized.html deleted file mode 100644 index eb57654..0000000 --- a/doc/space_optimized.html +++ /dev/null @@ -1,4171 +0,0 @@ - - - - - - Space Optimized Circular Buffer - - - - -

- Space Optimized Circular Buffer -

- - - - - -
-

- circular_buffer_space_optimized<T, Alloc> -

-
- Boost -
-

- Contents -

Description
- Synopsis
- Rationale
- Header Files
- Modelled concepts
- Specific Public Types
- Constructors and Destructor
- Specific Public Member Functions
- See also
- Acknowledgements -

- Description -

-

- 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. -

- - - - - - - - - -
- Space Optimized Circular Buffer -
- 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. -
-

- Synopsis -

-

- Note that some of the links point to the original circular_buffer - if the functionality is the same. -

-
- - - - -
-
-namespace boost {
-
-template <class T, class Alloc>
-class circular_buffer_space_optimized
-{
-public:
-   typedef typename Alloc::value_type value_type;
-   typedef typename Alloc::pointer pointer;
-   typedef typename Alloc::const_pointer const_pointer;
-   typedef typename Alloc::reference reference;
-   typedef typename Alloc::const_reference const_reference;
-   typedef typename Alloc::size_type size_type;
-   typedef typename Alloc::difference_type difference_type;
-   typedef Alloc allocator_type;
-   typedef implementation-defined const_iterator;
-   typedef implementation-defined iterator;
-   typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
-   typedef boost::reverse_iterator<iterator> reverse_iterator;
-   typedef std::pair<pointer, size_type> array_range;
-   typedef std::pair<const_pointer, size_type> const_array_range;
-   typedef implementation-defined capacity_type;
-
-   explicit circular_buffer_space_optimized(const allocator_type& alloc = allocator_type());
-   explicit circular_buffer_space_optimized(capacity_type capacity_ctrl, const allocator_type& alloc = allocator_type());
-   circular_buffer_space_optimized(capacity_type capacity_ctrl, const_reference item, const allocator_type& alloc = allocator_type());
-   circular_buffer_space_optimized(capacity_type capacity_ctrl, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
-   circular_buffer_space_optimized(const circular_buffer_space_optimized<T, Alloc>& cb);
-   template <class InputIterator>
-      circular_buffer_space_optimized(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
-   template <class InputIterator>
-      circular_buffer_space_optimized(capacity_type capacity_ctrl, InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
-   ~circular_buffer_space_optimized();
-
-   allocator_type get_allocator() const;
-   allocator_type& get_allocator();
-   iterator begin();
-   iterator end();
-   const_iterator begin() const;
-   const_iterator end() const;
-   reverse_iterator rbegin();
-   reverse_iterator rend();
-   const_reverse_iterator rbegin() const;
-   const_reverse_iterator rend() const;
-   reference operator[](size_type index);
-   const_reference operator[](size_type index) const;
-   reference at(size_type index);
-   const_reference at(size_type index) const;
-   reference front();
-   reference back();
-   const_reference front() const;
-   const_reference back() const;
-   array_range array_one();
-   array_range array_two();
-   const_array_range array_one() const;
-   const_array_range array_two() const;
-   pointer linearize();
-   size_type size() const;
-   size_type max_size() const;
-   bool empty() const;
-   bool full() const;
-   size_type reserve() const;
-   const capacity_type& capacity() const;
-   void set_capacity(const capacity_type& capacity_ctrl);
-   void resize(size_type new_size, const_reference item = value_type());
-   void rset_capacity(const capacity_type& capacity_ctrl);
-   void rresize(size_type new_size, const_reference item = value_type());
-   circular_buffer_space_optimized<T, Alloc>& operator=(const circular_buffer_space_optimized<T, Alloc>& cb);
-   void assign(size_type n, const_reference item);
-   void assign(capacity_type capacity_ctrl, size_type n, const_reference item);
-   template <class InputIterator>
-      void assign(InputIterator first, InputIterator last);
-   template <class InputIterator>
-      void assign(capacity_type capacity_ctrl, InputIterator first, InputIterator last);
-   void swap(circular_buffer_space_optimized<T, Alloc>& cb);
-   void push_back(const_reference item = value_type());
-   void push_front(const_reference item = value_type());
-   void pop_back();
-   void pop_front();
-   iterator insert(iterator pos, const_reference item = value_type());
-   void insert(iterator pos, size_type n, const_reference item);
-   template <class InputIterator>
-      void insert(iterator pos, InputIterator first, InputIterator last);
-   iterator rinsert(iterator pos, const_reference item = value_type());
-   void rinsert(iterator pos, size_type n, const_reference item);
-   template <class InputIterator>
-      void rinsert(iterator pos, InputIterator first, InputIterator last);
-   iterator erase(iterator pos);
-   iterator erase(iterator first, iterator last);
-   iterator rerase(iterator pos);
-   iterator rerase(iterator first, iterator last);
-   void clear();
-};
-
-template <class T, class Alloc>
-   bool operator==(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator<(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator!=(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator>(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator<=(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   bool operator>=(const circular_buffer_space_optimized<T, Alloc>& lhs, const circular_buffer_space_optimized<T, Alloc>& rhs);
-template <class T, class Alloc>
-   void swap(circular_buffer_space_optimized<T, Alloc>& lhs, circular_buffer_space_optimized<T, Alloc>& rhs);
-
-} // namespace boost
-
-
-
-

- Rationale -

-

- 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. -

-

- Header Files -

-

- 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. -

-

- Modelled concepts -

-

- Random Access Container, Front Insertion Sequence and Back Insertion Sequence. -

-

- Specific Public Types -

-

- 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. -

-
- - - - - - - - - -
- Type - - Description -
- capacity_type - - Capacity controller of the space optimized circular buffer. -
-class capacity_control {
-   size_type m_capacity;
-   size_type m_min_capacity;
-public:
-   capacity_control(size_type capacity, size_type min_capacity = 0) : m_capacity(capacity), m_min_capacity(min_capacity) {};
-   size_type capacity() const { return m_capacity; }
-   size_type min_capacity() const { return m_min_capacity; }
-   operator size_type() const { return m_capacity; }
-};
-
-
-
- Precondition: -
-
- capacity >= min_capacity -
-
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. -
-
-

- Constructors and Destructor -

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- 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). -
-
- Whatever T::T(const T&) throws. -
-
-
-
- Complexity: -
-
- Linear (in the n). -
-
-
- circular_buffer_space_optimized(const - circular_buffer_space_optimized<T,Alloc>& cb);
-
- The copy constructor. -

- 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). -
-
-
-
- See Also: -
-
- clear() -
-
-
-
-

- Specific Public Member Functions -

-

- 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). -
-
-
-
- See Also: -
-
- empty() -
-
-
- 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. -
-
- Returns: -
-
- capacity().capacity() - - size() -
-
-
-
- Throws: -
-
- Nothing. -
-
-
-
- Exception Safety: -
-
- No-throw. -
-
-
-
- Iterator Invalidation: -
-
- Does not invalidate any iterators. -
-
-
-
- Complexity: -
-
- Constant (in the size of the circular_buffer_space_optimized). -
-
-
-
- See Also: -
-
- capacity(), - size(), - max_size() -
-
-
- 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). -
-
-
-
- See Also: -
-
- reserve(), - size(), - max_size(), - set_capacity() -
-
-
- 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. -
-
-
-
- See Also: -
-
- rset_capacity(), - resize() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rresize(), - set_capacity() -
-
-
- 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()]). -
-
-
-
- See Also: -
-
- set_capacity(), - rresize() -
-
-
- 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). -
-
-
-
- See Also: -
-
- rresize(), - set_capacity() -
-
-
- circular_buffer_space_optimized<T,Alloc>& - operator=(const circular_buffer_space_optimized<T,Alloc>& cb);
-
- The assign operator. -

- Makes this circular_buffer_space_optimized to become 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. -
-
-
-
- Exception Safety: -
-
- Strong. -
-
-
-
- Iterator Invalidation: -
-
- Invalidates all iterators pointing to this circular_buffer_space_optimized (except - iterators equal to end()). -
-
-
-
- Complexity: -
-
- Linear (in the size of cb). -
-
-
-
- See Also: -
-
- assign(size_type, - const_reference), assign(capacity_type, - size_type, const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- void - assign(size_type n, - const_reference - item);
-
- Assign n items into the space optimized circular buffer. -

- The content of the circular_buffer_space_optimized will be removed and replaced with - n copies of the item. -

-
-
- Effect: -
-
- capacity().capacity() - == n && capacity().min_capacity() - == 0 && size() == n - && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] - == item
-
- The amount of allocated memory in the internal buffer is n. -
-
-
-
- Parameter(s): -
-
-
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in the n). -
-
-
-
- See Also: -
-
- operator=, - assign(capacity_type, - size_type, const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in the n). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(InputIterator, - InputIterator), assign(capacity_type, - InputIterator, InputIterator) -
-
-
- 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. -
-
-
-
- Effect: -
-
- capacity().capacity() - == std::distance(first, last) && capacity().min_capacity() - == 0 && size() == - std::distance(first, last) && (*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. -
-
-
-
-
-
- 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 std::distance(first, last)). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(capacity_type, - size_type, const_reference), assign(capacity_type, - InputIterator, 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). -
-
-
-
- See Also: -
-
- operator=, - assign(size_type, - const_reference), assign(capacity_type, - size_type, const_reference), assign(InputIterator, - InputIterator) -
-
-
- 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). -
-
-
-
- See Also: -
-
- swap(circular_buffer_space_optimized<T, - Alloc>&, circular_buffer_space_optimized<T, Alloc>&) -
-
-
- 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). -
-
-
-
- See Also: -
-
- push_front(), - pop_back(), - pop_front() -
-
-
- 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). -
-
-
-
- See Also: -
-
- push_back(), - pop_back(), - pop_front() -
-
-
- 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). -
-
-
-
- See Also: -
-
- pop_front(), - push_back(), - push_front() -
-
-
- 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). -
-
-
-
- See Also: -
-
- pop_back(), - push_back(), - push_front() -
-
-
- 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). -
-
-
-
- See Also: -
-
- insert(iterator, - size_type, value_type), insert(iterator, - InputIterator, InputIterator), rinsert(iterator, - value_type), rinsert(iterator, - size_type, value_type), rinsert(iterator, - InputIterator, InputIterator) -
-
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in min[capacity().capacity(), - size() + - n]). -
-
-
-
- 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 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|. -
-
-
-
- See Also: -
-
- insert(iterator, - value_type), insert(iterator, - InputIterator, InputIterator), rinsert(iterator, - value_type), rinsert(iterator, - size_type, value_type), rinsert(iterator, - InputIterator, InputIterator) -
-
-
- 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|. -
-
-
-
- See Also: -
-
- insert(iterator, - value_type), insert(iterator, - size_type, value_type), rinsert(iterator, - value_type), rinsert(iterator, - size_type, value_type), rinsert(iterator, - InputIterator, InputIterator) -
-
-
- 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). -
-
-
-
- See Also: -
-
- rinsert(iterator, - size_type, value_type), rinsert(iterator, - InputIterator, InputIterator), insert(iterator, - value_type), insert(iterator, - size_type, value_type), insert(iterator, - InputIterator, InputIterator) -
-
-
- 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()). -
-
-
-
- Complexity: -
-
- Linear (in min[capacity().capacity(), - size() + - n]). -
-
-
-
- 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 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|. -
-
-
-
- See Also: -
-
- rinsert(iterator, - value_type), rinsert(iterator, - InputIterator, InputIterator), insert(iterator, - value_type), insert(iterator, - size_type, value_type), insert(iterator, - InputIterator, InputIterator) -
-
-
- 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|. -
-
-
-
- See Also: -
-
- rinsert(iterator, - value_type), rinsert(iterator, - size_type, value_type), insert(iterator, - value_type), insert(iterator, - size_type, value_type), insert(iterator, - InputIterator, InputIterator) -
-
-
- iterator - erase(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()). -
-
-
-
- Effect: -
-
- The element at the position pos is removed.
-
- The amount of allocated memory in the internal buffer may be predictively decreased. -
-
-
-
- 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: -
-
- 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). -
-
-
-
- See Also: -
-
- erase(iterator, - iterator), rerase(iterator), - rerase(iterator, - iterator), clear() -
-
-
- iterator - erase(iterator first, - iterator - last);
-
- Erase the range [first, last). -
-
- Precondition: -
-
- Valid range [first, last). -
-
-
-
- Effect: -
-
- 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). -
-
-
-
- See Also: -
-
- erase(iterator), - rerase(iterator), - rerase(iterator, - iterator), clear() -
-
-
- 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). -
-
-
-
- See Also: -
-
- erase(iterator), - erase(iterator, - iterator), rerase(iterator, - iterator), clear() -
-
-
- iterator - rerase(iterator first, - iterator - last);
-
- Erase the range [first, last). -
-
- Precondition: -
-
- Valid range [first, last). -
-
-
-
- Effect: -
-
- 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). -
-
-
-
- See Also: -
-
- erase(iterator), - erase(iterator, - iterator), rerase(iterator), - clear() -
-
-
- void - clear();
-
- Remove all stored elements from the space optimized circular buffer. -
-
- Effect: -
-
- size() == - 0
-
- 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). -
-
-
-
- See Also: -
-
- ~circular_buffer_space_optimized(), - erase(iterator), - erase(iterator, - iterator), rerase(iterator), - rerase(iterator, - iterator) -
-
-
-
-

- See also -

-

- boost::circular_buffer, std::vector -

-

- Acknowledgements -

-

- The idea of the space optimized circular buffer has been introduced by Pavel Vozenilek. -

-
- - - - - - - - diff --git a/doc/space_optimized.png b/doc/space_optimized.png deleted file mode 100644 index 4f29f8c2834ac90b7ab1030c6debf88f14c7507a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25514 zcmeAS@N?(olHy`uVBq!ia0y~yVA{jLz!=BD#K6GtVox*!0|Ns~x}&cn14G2|Kkg4e z!V1YALB0$ORjLdO4b2P;KmRi@G(2NqDAi+NcoomUU^ShAK|DY6$q{V^hGbJu7srr_ zIY~e4x!ewFNU$zW5b0?ObYNlNP-tr`I{+6k;A&%I;8<|c?J$y12NMIM$*l~SE(0z% z#y|#z1~+M5h%p8rGZnZPST1BNP6U|?7LZ_dVQgTK$~Ea}3WN$QZqQ&5a9G^i1{X*W z5nyFt%Gh!drXoS4hiMUm14FNw6tY7_hJm9R4*dQ7{r>)X`<5J)XzNO;#;CIQ_j=a| z2B(0->sYkUF%1Qv-yH3`9k z%7OjBtAYh{8)Ox%d-k|7OG>@JzyJNKS6qqA(VPzE30)H&_JBh@fCUzr46F>=Ay)jB z0-P6Q+_t+hUkIuYW}JQk9Pup-(5Q3dN;^BNRGz0HRAkAd>i_?2C-9262e)Z*yyQL4 z#N5FVpzor(?w3%KY(Q8*fPtccg$|&S+KONt*ydk!>tZUNYYGXU|`yi&1T8aWFYXT zRQ}=e(nBiCCThv`zLewP)YGYuaHzU?;n$)+U(XpUIf$g*c&y5B<7Jz4*v9*!AxS>Z zUM}U*pH>?%p-KFE&Z;+l1(*ENieJ_W_cIukO7D7ID7RjmRZsDG!qeZUCuUtKRVz0t zmdmpBj?j~md!}CB6t?;+zbw;+bUk&31_PeCOMmmPJm|#nuV3lp+6h@-KdmagoM5XJ z(0;f`q3ey}c?Y!%-TyigR_t85RfK0E_w$n7E^0ideuTc;Xe06C;D)B{c4s$pz7P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SzzAk70 diff --git a/doc/space_optimized.xslt b/doc/space_optimized.xslt deleted file mode 100644 index 511bad2..0000000 --- a/doc/space_optimized.xslt +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/update_srcdoc.sh b/doc/update_srcdoc.sh deleted file mode 100644 index d1ad813..0000000 --- a/doc/update_srcdoc.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -################################################################################ -# Shell script which updates the Circular Buffer library documentation with # -# the latest source code documentation (which is in the source files). # -# # -# Copyright (c) 2007 Jan Gaspar # -# # -# 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) # -################################################################################ - -CONTAINER=$1 -DOCFILE="$CONTAINER.html" -XSLT="$CONTAINER.xslt" -XHTML="$CONTAINER.xhtml" -SPECIALIZATION=${CONTAINER#circular_buffer_} - -if [ ${#SPECIALIZATION} -gt 0 ]; then - DOCFILE=${DOCFILE#circular_buffer_} - XSLT=${XSLT#circular_buffer_} - XHTML=${XHTML#circular_buffer_} -fi - -if [ -f $DOCFILE ]; then - - echo Starting Doxygen ... - doxygen - - echo Converting Doxygen generated source code documentation into XHTML ... - xsltproc --stringparam container $CONTAINER --stringparam xmldir srcdoc -o srcdoc/srcdoc.xhtml $XSLT srcdoc/index.xml - - echo Preprocessing $DOCFILE ... - sed 's/ srcdoc/$DOCFILE - - echo Converting preprocessed $DOCFILE into XHTML ... - xsltproc --html -o srcdoc/$XHTML html2xhtml.xslt srcdoc/$DOCFILE - - echo Generating $DOCFILE with updated source code documentation ... - xsltproc --stringparam srcdoc srcdoc/srcdoc.xhtml -o $DOCFILE update_srcdoc.xslt srcdoc/$XHTML - - echo Correcting and pretty-printing $DOCFILE with HTML Tidy ... - tidy -ashtml -config Tidy.conf $DOCFILE - - echo Removing temporary directory ... - rm -rf srcdoc - - echo Done. - -else - - echo Usage: update_srcdoc.sh container - -fi diff --git a/doc/update_srcdoc.xslt b/doc/update_srcdoc.xslt deleted file mode 100644 index 11b84a1..0000000 --- a/doc/update_srcdoc.xslt +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/doc/valid-html40.png b/doc/valid-html40.png deleted file mode 100644 index ba02b4d8530a1a29efdac9ff3a55b7ce316bea20..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1444 zcmeAS@N?(olHy`uVBq!ia0y~yV2EH~V36lvW?*0l5&LzCfq|JJz$e7@|NsBS#>SSG zmR??7X=!OKEiE%=&OCGG%uEJ`G-HOPJ!#d&Y1L`Q&-W((Ka+N5rt#i6UJ?=<|Ns9t z?Aa<1RlW7v^W>$+qUP+Cs9x(eWiLb8%$BX!p1=RTcki*8#%T-;3=Itp{}~t<{xkds zQ~$xN|6oo7NSdJmOf@hxFf=qAIB?*=ode5GefahHDZcZgZWk z+I%qWb==E!+@tD@!NV0eqJ@c(MY@Ta4H=Fs{L94!d zGYn6k4p@`mn_~94M0NEdww3P>Hh*qd%bdTb_!`sqw49_fshgWD^%7*uODErL-79VI z?a1uK)@>JdUu&`HTGaV-z2tRYmqX@QnQ!19%0(K@?z zmh%>sH0MstJO9@)^<(0m)~Q!c%eDx#-@ha2_I=SAlV4BW%&qwqkMd|MZWY;XIsdLC z-=3lf(_76o%DWkreYc(|5L+8GZ&`MEBfHYY!d#BVhxWyt-_s)=e*8MgicRsn-s$Xe z%a#>qFKv6RnHjP>p-BGx29fq$3)4eOcOQ@y-|lR?VQy{zp((qSrW9>m%KvD=v>=ro zJ9OUsDXz?E+cw+%it^frH%ubW9Oe{rS|oPVtvB6hXZZ8N7eCIV+}+NspQ!mMY3ou| zCy$dWgpTggo^cU diff --git a/index.html b/index.html deleted file mode 100644 index f328736..0000000 --- a/index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Redirection - - - - Automatic redirection failed, please go to circular_buffer.html. -

- Copyright © 2003-2007 Jan Gaspar -

-

- Use, modification, and distribution is subject to the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-

- - diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index ed94069..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,17 +0,0 @@ -# Boost circular_buffer test Jamfile. -# -# 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) - -# Bring in rules for testing. -import testing ; - -test-suite "circular_buffer" - : [ run base_test.cpp : single : ] - [ run space_optimized_test.cpp : single : ] - [ run soft_iterator_invalidation.cpp : single : ] - [ compile bounded_buffer_comparison.cpp : multi : ] - ; diff --git a/test/base_test.cpp b/test/base_test.cpp deleted file mode 100644 index 5386137..0000000 --- a/test/base_test.cpp +++ /dev/null @@ -1,704 +0,0 @@ -// Test of the base circular buffer container. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include "test.hpp" - -#define CB_CONTAINER circular_buffer - -#include "common.ipp" - -void iterator_constructor_and_assign_test() { - - circular_buffer cb(4, 3); - circular_buffer::iterator it = cb.begin(); - circular_buffer::iterator itCopy; - itCopy = it; - it = it; - circular_buffer::const_iterator cit; - cit = it; - circular_buffer::const_iterator end1 = cb.end(); - circular_buffer::const_iterator end2 = end1; - - BOOST_CHECK(itCopy == it); - BOOST_CHECK(cit == it); - BOOST_CHECK(end1 == end2); - BOOST_CHECK(it != end1); - BOOST_CHECK(cit != end2); -} - -void iterator_reference_test() { - - circular_buffer cb(3, Dummy()); - circular_buffer::iterator it = cb.begin(); - circular_buffer::const_iterator cit = cb.begin() + 1; - - BOOST_CHECK((*it).m_n == Dummy::eVar); - BOOST_CHECK((*it).fnc() == Dummy::eFnc); - BOOST_CHECK((*cit).const_fnc() == Dummy::eConst); - BOOST_CHECK((*it).virtual_fnc() == Dummy::eVirtual); - BOOST_CHECK(it->m_n == Dummy::eVar); - BOOST_CHECK(it->fnc() == Dummy::eFnc); - BOOST_CHECK(cit->const_fnc() == Dummy::eConst); - BOOST_CHECK(it->virtual_fnc() == Dummy::eVirtual); -} - -void iterator_difference_test() { - - circular_buffer cb(5, 1); - cb.push_back(2); - circular_buffer::iterator it1 = cb.begin() + 2; - circular_buffer::iterator it2 = cb.begin() + 3; - circular_buffer::const_iterator begin = cb.begin(); - circular_buffer::iterator end = cb.end(); - - BOOST_CHECK(begin - begin == 0); - BOOST_CHECK(end - cb.begin() == 5); - BOOST_CHECK(end - end == 0); - BOOST_CHECK(begin - cb.end() == -5); - BOOST_CHECK(it1 - cb.begin() == 2); - BOOST_CHECK(end - it1 == 3); - BOOST_CHECK(it2 - it1 == 1); - BOOST_CHECK(it1 - it2 == -1); - BOOST_CHECK(it2 - it2 == 0); -} - -void iterator_increment_test() { - - circular_buffer cb(10, 1); - cb.push_back(2); - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 5; - circular_buffer::iterator it3 = cb.begin() + 9; - it1++; - it2++; - ++it3; - - BOOST_CHECK(it1 == cb.begin() + 1); - BOOST_CHECK(it2 == cb.begin() + 6); - BOOST_CHECK(it3 == cb.end()); -} - -void iterator_decrement_test() { - - circular_buffer cb(10, 1); - cb.push_back(2); - circular_buffer::iterator it1= cb.end(); - circular_buffer::iterator it2= cb.end() - 5; - circular_buffer::iterator it3= cb.end() - 9; - --it1; - it2--; - --it3; - - BOOST_CHECK(it1 == cb.end() - 1); - BOOST_CHECK(it2 == cb.end() - 6); - BOOST_CHECK(it3 == cb.begin()); -} - -void iterator_addition_test() { - - circular_buffer cb(10, 1); - cb.push_back(2); - cb.push_back(2); - circular_buffer::iterator it1 = cb.begin() + 2; - circular_buffer::iterator it2 = cb.end(); - circular_buffer::iterator it3 = cb.begin() + 5; - circular_buffer::iterator it4 = cb.begin() + 9; - it1 += 3; - it2 += 0; - it3 += 5; - it4 += -2; - - BOOST_CHECK(it1 == 5 + cb.begin()); - BOOST_CHECK(it2 == cb.end()); - BOOST_CHECK(it3 == cb.end()); - BOOST_CHECK(it4 + 3 == cb.end()); - BOOST_CHECK((-3) + it4 == cb.begin() + 4); - BOOST_CHECK(cb.begin() + 0 == cb.begin()); -} - -void iterator_subtraction_test() { - - circular_buffer cb(10, 1); - cb.push_back(2); - cb.push_back(2); - cb.push_back(2); - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.end(); - circular_buffer::iterator it3 = cb.end() - 5; - circular_buffer::iterator it4 = cb.begin() + 7; - it1 -= -2; - it2 -= 0; - it3 -= 5; - - BOOST_CHECK(it1 == cb.begin() + 2); - BOOST_CHECK(it2 == cb.end()); - BOOST_CHECK(it3 == cb.begin()); - BOOST_CHECK(it4 - 7 == cb.begin()); - BOOST_CHECK(it4 - (-3) == cb.end()); - BOOST_CHECK(cb.begin() - 0 == cb.begin()); -} - -void iterator_element_access_test() { - - circular_buffer cb(10); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - cb.push_back(6); - circular_buffer::iterator it = cb.begin() + 1; - - BOOST_CHECK(it[0] == 2); - BOOST_CHECK(it[-1] == 1); - BOOST_CHECK(it[2] == 4); -} - -void iterator_comparison_test() { - - circular_buffer cb(5, 1); - cb.push_back(2); - circular_buffer::iterator it = cb.begin() + 2; - circular_buffer::const_iterator begin = cb.begin(); - circular_buffer::iterator end = cb.end(); - - BOOST_CHECK(begin == begin); - BOOST_CHECK(end > cb.begin()); - BOOST_CHECK(begin < end); - BOOST_CHECK(end > begin); - BOOST_CHECK(end == end); - BOOST_CHECK(begin < cb.end()); - BOOST_CHECK(!(begin + 1 > cb.end())); - BOOST_CHECK(it > cb.begin()); - BOOST_CHECK(end > it); - BOOST_CHECK(begin >= begin); - BOOST_CHECK(end >= cb.begin()); - BOOST_CHECK(end <= end); - BOOST_CHECK(begin <= cb.end()); - BOOST_CHECK(it >= cb.begin()); - BOOST_CHECK(end >= it); - BOOST_CHECK(!(begin + 4 < begin + 4)); - BOOST_CHECK(begin + 4 < begin + 5); - BOOST_CHECK(!(begin + 5 < begin + 4)); - BOOST_CHECK(it < end - 1); - BOOST_CHECK(!(end - 1 < it)); -} - -// TODO add insert, push_back etc. -void iterator_invalidation_test() { - -#if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG) - - circular_buffer::iterator it1; - circular_buffer::const_iterator it2; - circular_buffer::iterator it3; - circular_buffer::const_iterator it4; - circular_buffer::const_iterator it5; - circular_buffer::const_iterator it6; - - BOOST_CHECK(it1.is_valid(0)); - BOOST_CHECK(it2.is_valid(0)); - BOOST_CHECK(it3.is_valid(0)); - BOOST_CHECK(it4.is_valid(0)); - BOOST_CHECK(it5.is_valid(0)); - BOOST_CHECK(it6.is_valid(0)); - - { - circular_buffer cb(5, 0); - const circular_buffer ccb(5, 0); - - it1 = cb.begin(); - it2 = ccb.begin(); - it3 = cb.end(); - it4 = it1; - it5 = it2; - it6 = it1; - - BOOST_CHECK(it1.is_valid(&cb)); - BOOST_CHECK(it2.is_valid(&ccb)); - BOOST_CHECK(it3.is_valid(&cb)); - BOOST_CHECK(it4.is_valid(&cb)); - BOOST_CHECK(it5.is_valid(&ccb)); - BOOST_CHECK(it6.is_valid(&cb)); - } - - BOOST_CHECK(it1.is_valid(0)); - BOOST_CHECK(it2.is_valid(0)); - BOOST_CHECK(it3.is_valid(0)); - BOOST_CHECK(it4.is_valid(0)); - BOOST_CHECK(it5.is_valid(0)); - BOOST_CHECK(it6.is_valid(0)); - - circular_buffer cb(10, 0); - it1 = cb.end(); - cb.clear(); - BOOST_CHECK(it1.is_valid(&cb)); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - int i = 0; - for (it2 = cb.begin(); it2 != it1; it2++, i++); - BOOST_CHECK(i == 3); - - circular_buffer cb1(10, 0); - circular_buffer cb2(20, 0); - it1 = cb1.end(); - it2 = cb2.begin(); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(it2.is_valid(&cb2)); - - cb1.swap(cb2); - BOOST_CHECK(!it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb2)); - - it1 = cb1.begin() + 3; - it2 = cb1.begin(); - cb1.push_back(1); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(*it2.m_it == 1); - - circular_buffer cb3(5); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - cb3.push_back(4); - cb3.push_back(5); - it1 = cb3.begin() + 2; - it2 = cb3.begin(); - cb3.insert(cb3.begin() + 3, 6); - BOOST_CHECK(it1.is_valid(&cb3)); - BOOST_CHECK(!it2.is_valid(&cb3)); - BOOST_CHECK(*it2.m_it == 5); - - it1 = cb3.begin() + 3; - it2 = cb3.end() - 1; - cb3.push_front(7); - BOOST_CHECK(it1.is_valid(&cb3)); - BOOST_CHECK(!it2.is_valid(&cb3)); - BOOST_CHECK(*it2.m_it == 7); - - circular_buffer cb4(5); - cb4.push_back(1); - cb4.push_back(2); - cb4.push_back(3); - cb4.push_back(4); - cb4.push_back(5); - it1 = cb4.begin() + 3; - it2 = cb4.begin(); - cb4.rinsert(cb4.begin() + 2, 6); - BOOST_CHECK(it1.is_valid(&cb4)); - BOOST_CHECK(!it2.is_valid(&cb4)); - BOOST_CHECK(*it2.m_it == 2); - - it1 = cb1.begin() + 5; - it2 = cb1.end() - 1; - cb1.pop_back(); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - - it1 = cb1.begin() + 5; - it2 = cb1.begin(); - cb1.pop_front(); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - - circular_buffer cb5(20, 0); - it1 = cb5.begin() + 5; - it2 = it3 = cb5.begin() + 15; - cb5.erase(cb5.begin() + 10); - BOOST_CHECK(it1.is_valid(&cb5)); - BOOST_CHECK(!it2.is_valid(&cb5)); - BOOST_CHECK(!it3.is_valid(&cb5)); - - it1 = cb5.begin() + 1; - it2 = it3 = cb5.begin() + 8; - cb5.erase(cb5.begin() + 3, cb5.begin() + 7); - BOOST_CHECK(it1.is_valid(&cb5)); - BOOST_CHECK(!it2.is_valid(&cb5)); - BOOST_CHECK(!it3.is_valid(&cb5)); - - circular_buffer cb6(20, 0); - it4 = it1 = cb6.begin() + 5; - it2 = cb6.begin() + 15; - cb6.rerase(cb6.begin() + 10); - BOOST_CHECK(!it1.is_valid(&cb6)); - BOOST_CHECK(!it4.is_valid(&cb6)); - BOOST_CHECK(it2.is_valid(&cb6)); - - it4 = it1 = cb6.begin() + 1; - it2 = cb6.begin() + 8; - cb6.rerase(cb6.begin() + 3, cb6.begin() + 7); - BOOST_CHECK(!it1.is_valid(&cb6)); - BOOST_CHECK(!it4.is_valid(&cb6)); - BOOST_CHECK(it2.is_valid(&cb6)); - - circular_buffer cb7(10, 1); - cb7.push_back(2); - cb7.push_back(3); - cb7.push_back(4); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.linearize(); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(!it2.is_valid(&cb7)); - BOOST_CHECK(!it3.is_valid(&cb7)); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.linearize(); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(it2.is_valid(&cb7)); - BOOST_CHECK(it3.is_valid(&cb7)); - - cb7.push_back(5); - cb7.push_back(6); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.set_capacity(10); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(it2.is_valid(&cb7)); - BOOST_CHECK(it3.is_valid(&cb7)); - cb7.set_capacity(20); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(!it2.is_valid(&cb7)); - BOOST_CHECK(!it3.is_valid(&cb7)); - cb7.push_back(7); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.set_capacity(10); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(!it2.is_valid(&cb7)); - BOOST_CHECK(!it3.is_valid(&cb7)); - - cb7.push_back(8); - cb7.push_back(9); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.rset_capacity(10); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(it2.is_valid(&cb7)); - BOOST_CHECK(it3.is_valid(&cb7)); - cb7.rset_capacity(20); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(!it2.is_valid(&cb7)); - BOOST_CHECK(!it3.is_valid(&cb7)); - cb7.push_back(10); - it1 = cb7.end(); - it2 = cb7.begin(); - it3 = cb7.begin() + 6; - cb7.rset_capacity(10); - BOOST_CHECK(it1.is_valid(&cb7)); - BOOST_CHECK(!it2.is_valid(&cb7)); - BOOST_CHECK(!it3.is_valid(&cb7)); - - circular_buffer cb8(10, 1); - cb8.push_back(2); - cb8.push_back(3); - it1 = cb8.end(); - it2 = cb8.begin(); - it3 = cb8.begin() + 6; - cb8.resize(10); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(it2.is_valid(&cb8)); - BOOST_CHECK(it3.is_valid(&cb8)); - cb8.resize(20); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(!it2.is_valid(&cb8)); - BOOST_CHECK(!it3.is_valid(&cb8)); - cb8.push_back(4); - it1 = cb8.end(); - it2 = cb8.begin(); - it3 = cb8.begin() + 6; - it4 = cb8.begin() + 12; - cb8.resize(10); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(it2.is_valid(&cb8)); - BOOST_CHECK(it3.is_valid(&cb8)); - BOOST_CHECK(!it4.is_valid(&cb8)); - - cb8.set_capacity(10); - cb8.push_back(5); - cb8.push_back(6); - it1 = cb8.end(); - it2 = cb8.begin(); - it3 = cb8.begin() + 6; - cb8.rresize(10); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(it2.is_valid(&cb8)); - BOOST_CHECK(it3.is_valid(&cb8)); - cb8.rresize(20); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(!it2.is_valid(&cb8)); - BOOST_CHECK(!it3.is_valid(&cb8)); - cb8.push_back(7); - it1 = cb8.end(); - it2 = cb8.begin(); - it3 = cb8.begin() + 6; - it4 = cb8.begin() + 12; - cb8.rresize(10); - BOOST_CHECK(it1.is_valid(&cb8)); - BOOST_CHECK(!it2.is_valid(&cb8)); - BOOST_CHECK(!it3.is_valid(&cb8)); - BOOST_CHECK(it4.is_valid(&cb8)); - - circular_buffer cb9(15, 1); - it1 = cb9.end(); - it2 = cb9.begin(); - it3 = cb9.begin() + 6; - it4 = cb9.begin() + 12; - cb9 = cb8; - BOOST_CHECK(it1.is_valid(&cb9)); - BOOST_CHECK(!it2.is_valid(&cb9)); - BOOST_CHECK(!it3.is_valid(&cb9)); - BOOST_CHECK(!it4.is_valid(&cb9)); - - circular_buffer cb10(10, 1); - it1 = cb10.end(); - it2 = cb10.begin(); - it3 = cb10.begin() + 3; - it4 = cb10.begin() + 7; - cb10.assign(5, 2); - BOOST_CHECK(it1.is_valid(&cb10)); - BOOST_CHECK(!it2.is_valid(&cb10)); - BOOST_CHECK(!it3.is_valid(&cb10)); - BOOST_CHECK(!it4.is_valid(&cb10)); - - circular_buffer cb11(10, 1); - it1 = cb11.end(); - it2 = cb11.begin(); - it3 = cb11.begin() + 3; - it4 = cb11.begin() + 7; - cb11.assign(15, 5, 2); - BOOST_CHECK(it1.is_valid(&cb11)); - BOOST_CHECK(!it2.is_valid(&cb11)); - BOOST_CHECK(!it3.is_valid(&cb11)); - BOOST_CHECK(!it4.is_valid(&cb11)); - - circular_buffer cb12(10, 1); - it1 = cb12.end(); - it2 = cb12.begin(); - it3 = cb12.begin() + 3; - it4 = cb12.begin() + 7; - cb12.assign(cb11.begin(), cb11.end()); - BOOST_CHECK(it1.is_valid(&cb12)); - BOOST_CHECK(!it2.is_valid(&cb12)); - BOOST_CHECK(!it3.is_valid(&cb12)); - BOOST_CHECK(!it4.is_valid(&cb12)); - - circular_buffer cb13(10, 1); - it1 = cb13.end(); - it2 = cb13.begin(); - it3 = cb13.begin() + 3; - it4 = cb13.begin() + 7; - cb13.assign(15, cb11.begin(), cb11.end()); - BOOST_CHECK(it1.is_valid(&cb13)); - BOOST_CHECK(!it2.is_valid(&cb13)); - BOOST_CHECK(!it3.is_valid(&cb13)); - BOOST_CHECK(!it4.is_valid(&cb13)); - -#endif // #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG) -} - -// basic exception safety test (it is useful to use any memory-leak detection tool) -void exception_safety_test() { - -#if !defined(BOOST_NO_EXCEPTIONS) - - circular_buffer cb1(3, 5); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb1.set_capacity(5), std::exception); - BOOST_CHECK(cb1.capacity() == 3); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb1.rset_capacity(5), std::exception); - BOOST_CHECK(cb1.capacity() == 3); - generic_test(cb1); - - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(circular_buffer cb2(5, 10), std::exception); - - circular_buffer cb3(5, 10); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(circular_buffer cb4(cb3), std::exception); - - vector v(5, MyInteger(10)); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(circular_buffer cb5(8, v.begin(), v.end()), std::exception); - - circular_buffer cb6(5, 10); - circular_buffer cb7(8, 3); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb7 = cb6, std::exception); - BOOST_CHECK(cb7.size() == 8); - BOOST_CHECK(cb7.capacity() == 8); - BOOST_CHECK(cb7[0] == 3); - BOOST_CHECK(cb7[7] == 3); - generic_test(cb7); - - circular_buffer cb8(5, 10); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb8.push_front(1), std::exception); - - circular_buffer cb9(5); - cb9.push_back(1); - cb9.push_back(2); - cb9.push_back(3); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb9.insert(cb9.begin() + 1, 4), std::exception); - - circular_buffer cb10(5); - cb10.push_back(1); - cb10.push_back(2); - cb10.push_back(3); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb10.rinsert(cb10.begin() + 1, 4), std::exception); - - circular_buffer cb11(5); - cb11.push_back(1); - cb11.push_back(2); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb11.rinsert(cb11.begin(), 1), std::exception); - - circular_buffer cb12(5, 1); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb12.assign(4, 2), std::exception); - - circular_buffer cb13(5, 1); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb13.assign(6, 2), std::exception); - - circular_buffer cb14(5); - cb14.push_back(1); - cb14.push_back(2); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb14.insert(cb14.begin(), 10, 3), std::exception); - - circular_buffer cb15(5); - cb15.push_back(1); - cb15.push_back(2); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb15.insert(cb15.end(), 10, 3), std::exception); - - circular_buffer cb16(5); - cb16.push_back(1); - cb16.push_back(2); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb16.rinsert(cb16.begin(), 10, 3), std::exception); - - circular_buffer cb17(5); - cb17.push_back(1); - cb17.push_back(2); - MyInteger::set_exception_trigger(3); - BOOST_CHECK_THROW(cb17.rinsert(cb17.end(), 10, 3), std::exception); - - circular_buffer cb18(5, 0); - cb18.push_back(1); - cb18.push_back(2); - cb18.pop_front(); - MyInteger::set_exception_trigger(4); - BOOST_CHECK_THROW(cb18.linearize(), std::exception); - - circular_buffer cb19(5, 0); - cb19.push_back(1); - cb19.push_back(2); - MyInteger::set_exception_trigger(5); - BOOST_CHECK_THROW(cb19.linearize(), std::exception); - - circular_buffer cb20(5, 0); - cb20.push_back(1); - cb20.push_back(2); - MyInteger::set_exception_trigger(6); - BOOST_CHECK_THROW(cb20.linearize(), std::exception); - - circular_buffer cb21(5); - cb21.push_back(1); - cb21.push_back(2); - cb21.push_back(3); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb21.insert(cb21.begin() + 1, 4), std::exception); - - circular_buffer cb22(5); - cb22.push_back(1); - cb22.push_back(2); - cb22.push_back(3); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb22.insert(cb22.end(), 4), std::exception); - - circular_buffer cb23(5, 0); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb23.insert(cb23.begin() + 1, 4), std::exception); - - circular_buffer cb24(5); - cb24.push_back(1); - cb24.push_back(2); - cb24.push_back(3); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb24.rinsert(cb24.begin() + 1, 4), std::exception); - - circular_buffer cb25(5, 0); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb25.rinsert(cb25.begin() + 3, 4), std::exception); - - circular_buffer cb26(5); - cb26.push_back(1); - cb26.push_back(2); - MyInteger::set_exception_trigger(5); - BOOST_CHECK_THROW(cb26.insert(cb26.begin(), 10, 3), std::exception); - - circular_buffer cb27(5); - cb27.push_back(1); - cb27.push_back(2); - MyInteger::set_exception_trigger(5); - BOOST_CHECK_THROW(cb27.insert(cb27.end(), 10, 3), std::exception); - - circular_buffer cb28(5); - cb28.push_back(1); - cb28.push_back(2); - MyInteger::set_exception_trigger(5); - BOOST_CHECK_THROW(cb28.rinsert(cb28.begin(), 10, 3), std::exception); - - circular_buffer cb29(5); - cb29.push_back(1); - cb29.push_back(2); - MyInteger::set_exception_trigger(5); - BOOST_CHECK_THROW(cb29.rinsert(cb29.end(), 10, 3), std::exception); - - circular_buffer cb30(10); - cb30.push_back(1); - cb30.push_back(2); - cb30.push_back(3); - MyInteger::set_exception_trigger(2); - BOOST_CHECK_THROW(cb30.rinsert(cb30.begin(), 10, 3), std::exception); - -#endif // #if !defined(BOOST_NO_EXCEPTIONS) -} - -// test main -test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) { - - test_suite* tests = BOOST_TEST_SUITE("Unit tests for the circular_buffer."); - add_common_tests(tests); - - tests->add(BOOST_TEST_CASE(&iterator_constructor_and_assign_test)); - tests->add(BOOST_TEST_CASE(&iterator_reference_test)); - tests->add(BOOST_TEST_CASE(&iterator_difference_test)); - tests->add(BOOST_TEST_CASE(&iterator_increment_test)); - tests->add(BOOST_TEST_CASE(&iterator_decrement_test)); - tests->add(BOOST_TEST_CASE(&iterator_addition_test)); - tests->add(BOOST_TEST_CASE(&iterator_subtraction_test)); - tests->add(BOOST_TEST_CASE(&iterator_element_access_test)); - tests->add(BOOST_TEST_CASE(&iterator_comparison_test)); - tests->add(BOOST_TEST_CASE(&iterator_invalidation_test)); - tests->add(BOOST_TEST_CASE(&exception_safety_test)); - - return tests; -} diff --git a/test/bounded_buffer_comparison.cpp b/test/bounded_buffer_comparison.cpp deleted file mode 100644 index 9a48685..0000000 --- a/test/bounded_buffer_comparison.cpp +++ /dev/null @@ -1,288 +0,0 @@ -// Comparison of bounded buffers based on different containers. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_CB_DISABLE_DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const unsigned long QUEUE_SIZE = 1000L; -const unsigned long TOTAL_ELEMENTS = QUEUE_SIZE * 1000L; - -template -class bounded_buffer { -public: - - typedef boost::circular_buffer container_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::value_type value_type; - - explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {} - - void push_front(const value_type& item) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_full.wait(lock, boost::bind(&bounded_buffer::is_not_full, this)); - m_container.push_front(item); - ++m_unread; - lock.unlock(); - m_not_empty.notify_one(); - } - - void pop_back(value_type* pItem) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_empty.wait(lock, boost::bind(&bounded_buffer::is_not_empty, this)); - *pItem = m_container[--m_unread]; - lock.unlock(); - m_not_full.notify_one(); - } - -private: - bounded_buffer(const bounded_buffer&); // Disabled copy constructor - bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator - - bool is_not_empty() const { return m_unread > 0; } - bool is_not_full() const { return m_unread < m_container.capacity(); } - - size_type m_unread; - container_type m_container; - boost::mutex m_mutex; - boost::condition m_not_empty; - boost::condition m_not_full; -}; - -template -class bounded_buffer_space_optimized { -public: - - typedef boost::circular_buffer_space_optimized container_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::value_type value_type; - - explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {} - - void push_front(const value_type& item) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized::is_not_full, this)); - m_container.push_front(item); - lock.unlock(); - m_not_empty.notify_one(); - } - - void pop_back(value_type* pItem) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_empty.wait(lock, boost::bind(&bounded_buffer_space_optimized::is_not_empty, this)); - *pItem = m_container.back(); - m_container.pop_back(); - lock.unlock(); - m_not_full.notify_one(); - } - -private: - - bounded_buffer_space_optimized(const bounded_buffer_space_optimized&); // Disabled copy constructor - bounded_buffer_space_optimized& operator = (const bounded_buffer_space_optimized&); // Disabled assign operator - - bool is_not_empty() const { return m_container.size() > 0; } - bool is_not_full() const { return m_container.size() < m_container.capacity(); } - - container_type m_container; - boost::mutex m_mutex; - boost::condition m_not_empty; - boost::condition m_not_full; -}; - -template -class bounded_buffer_deque_based { -public: - - typedef std::deque container_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::value_type value_type; - - explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {} - - void push_front(const value_type& item) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based::is_not_full, this)); - m_container.push_front(item); - lock.unlock(); - m_not_empty.notify_one(); - } - - void pop_back(value_type* pItem) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_empty.wait(lock, boost::bind(&bounded_buffer_deque_based::is_not_empty, this)); - *pItem = m_container.back(); - m_container.pop_back(); - lock.unlock(); - m_not_full.notify_one(); - } - -private: - - bounded_buffer_deque_based(const bounded_buffer_deque_based&); // Disabled copy constructor - bounded_buffer_deque_based& operator = (const bounded_buffer_deque_based&); // Disabled assign operator - - bool is_not_empty() const { return m_container.size() > 0; } - bool is_not_full() const { return m_container.size() < m_capacity; } - - const size_type m_capacity; - container_type m_container; - boost::mutex m_mutex; - boost::condition m_not_empty; - boost::condition m_not_full; -}; - -template -class bounded_buffer_list_based { -public: - - typedef std::list container_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::value_type value_type; - - explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {} - - void push_front(const value_type& item) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based::is_not_full, this)); - m_container.push_front(item); - lock.unlock(); - m_not_empty.notify_one(); - } - - void pop_back(value_type* pItem) { - boost::mutex::scoped_lock lock(m_mutex); - m_not_empty.wait(lock, boost::bind(&bounded_buffer_list_based::is_not_empty, this)); - *pItem = m_container.back(); - m_container.pop_back(); - lock.unlock(); - m_not_full.notify_one(); - } - -private: - - bounded_buffer_list_based(const bounded_buffer_list_based&); // Disabled copy constructor - bounded_buffer_list_based& operator = (const bounded_buffer_list_based&); // Disabled assign operator - - bool is_not_empty() const { return m_container.size() > 0; } - bool is_not_full() const { return m_container.size() < m_capacity; } - - const size_type m_capacity; - container_type m_container; - boost::mutex m_mutex; - boost::condition m_not_empty; - boost::condition m_not_full; -}; - -template -class Consumer { - - typedef typename Buffer::value_type value_type; - Buffer* m_container; - value_type m_item; - -public: - Consumer(Buffer* buffer) : m_container(buffer) {} - - void operator()() { - for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) { - m_container->pop_back(&m_item); - } - } -}; - -template -class Producer { - - typedef typename Buffer::value_type value_type; - Buffer* m_container; - -public: - Producer(Buffer* buffer) : m_container(buffer) {} - - void operator()() { - for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) { - m_container->push_front(value_type()); - } - } -}; - -template -void fifo_test(Buffer* buffer) { - - // Start of measurement - boost::progress_timer progress; - - // Initialize the buffer with some values before launching producer and consumer threads. - for (unsigned long i = QUEUE_SIZE / 2L; i > 0; --i) { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) - buffer->push_front(Buffer::value_type()); -#else - buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type()); -#endif - } - - Consumer consumer(buffer); - Producer producer(buffer); - - // Start the threads. - boost::thread consume(consumer); - boost::thread produce(producer); - - // Wait for completion. - consume.join(); - produce.join(); - - // End of measurement -} - -int main(int /*argc*/, char* /*argv*/[]) { - - bounded_buffer bb_int(QUEUE_SIZE); - std::cout << "bounded_buffer "; - fifo_test(&bb_int); - - bounded_buffer_space_optimized bb_space_optimized_int(QUEUE_SIZE); - std::cout << "bounded_buffer_space_optimized "; - fifo_test(&bb_space_optimized_int); - - bounded_buffer_deque_based bb_deque_based_int(QUEUE_SIZE); - std::cout << "bounded_buffer_deque_based "; - fifo_test(&bb_deque_based_int); - - bounded_buffer_list_based bb_list_based_int(QUEUE_SIZE); - std::cout << "bounded_buffer_list_based "; - fifo_test(&bb_list_based_int); - - bounded_buffer bb_string(QUEUE_SIZE); - std::cout << "bounded_buffer "; - fifo_test(&bb_string); - - bounded_buffer_space_optimized bb_space_optimized_string(QUEUE_SIZE); - std::cout << "bounded_buffer_space_optimized "; - fifo_test(&bb_space_optimized_string); - - bounded_buffer_deque_based bb_deque_based_string(QUEUE_SIZE); - std::cout << "bounded_buffer_deque_based "; - fifo_test(&bb_deque_based_string); - - bounded_buffer_list_based bb_list_based_string(QUEUE_SIZE); - std::cout << "bounded_buffer_list_based "; - fifo_test(&bb_list_based_string); - - return 0; -} diff --git a/test/common.ipp b/test/common.ipp deleted file mode 100644 index 8b248d9..0000000 --- a/test/common.ipp +++ /dev/null @@ -1,1827 +0,0 @@ -// Common tests for the circular buffer and its adaptor. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -void generic_test(CB_CONTAINER& cb) { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - v.push_back(14); - v.push_back(15); - v.push_back(16); - v.push_back(17); - - if (cb.capacity() == 0) { - - cb.insert(cb.begin(), 1); - cb.insert(cb.begin(), v.begin(), v.end()); - cb.rinsert(cb.end(), 2); - cb.rinsert(cb.end(), v.begin(), v.end()); - cb.push_back(3); - cb.push_front(4); - cb.linearize(); - - BOOST_CHECK(cb.empty()); - BOOST_CHECK(cb.full()); - - } else { - - cb.insert(cb.end(), 1); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[cb.size() - 1] == 1); - - size_t size = cb.size(); - cb.rerase(cb.end() - 1, cb.end()); - BOOST_CHECK(size == cb.size() + 1); - - cb.insert(cb.end(), v.begin(), v.end()); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[cb.size() - 1] == 17); - - size = cb.size(); - cb.erase(cb.end() - 1, cb.end()); - BOOST_CHECK(size == cb.size() + 1); - - size = cb.size(); - cb.rinsert(cb.begin(), 2); - BOOST_CHECK(size + 1 == cb.size()); - BOOST_CHECK(cb[0] == 2); - - size = cb.size(); - cb.erase(cb.begin()); - BOOST_CHECK(size == cb.size() + 1); - - cb.rinsert(cb.begin(), v.begin(), v.end()); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[0] == 11); - - size = cb.size(); - cb.pop_front(); - BOOST_CHECK(size == cb.size() + 1); - - cb.push_back(3); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[cb.size() - 1] == 3); - - size = cb.size(); - cb.pop_back(); - BOOST_CHECK(size == cb.size() + 1); - - cb.push_front(4); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[0] == 4); - - cb.linearize(); - BOOST_CHECK(!cb.empty()); - BOOST_CHECK(cb[0] == 4); - - size = cb.size(); - cb.rerase(cb.begin()); - BOOST_CHECK(size == cb.size() + 1); - } -} - -void basic_test() { - - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - v.push_back(6); - v.push_back(7); - CB_CONTAINER cb1(3, v.begin(), v.end()); - CB_CONTAINER cb2(10, v.begin(), v.end()); - CB_CONTAINER cb3(7, v.begin(), v.end()); - - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1.capacity() == 3); - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1[0] == 5); - BOOST_CHECK(cb1[2] == 7); - BOOST_CHECK(!cb2.full()); - BOOST_CHECK(cb2[2] == 3); - BOOST_CHECK(cb3.full()); - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[6] == 7); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void constructor_and_element_access_test() { - - CB_CONTAINER cb(5, 3); - cb[1] = 10; - - BOOST_CHECK(cb.full()); - BOOST_CHECK(cb[1] == 10); - BOOST_CHECK(cb[4] == 3); -} - -void size_test() { - - CB_CONTAINER cb1(3); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - CB_CONTAINER cb2(5); - - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb2.size() == 0); - BOOST_CHECK(cb1.max_size() == cb2.max_size()); - - generic_test(cb1); - generic_test(cb2); -} - -void allocator_test() { - - CB_CONTAINER cb1(10, 0); - const CB_CONTAINER cb2(10, 0); - CB_CONTAINER::allocator_type& alloc_ref = cb1.get_allocator(); - CB_CONTAINER::allocator_type alloc = cb2.get_allocator(); - alloc_ref.max_size(); - alloc.max_size(); - - generic_test(cb1); -} - -void begin_and_end_test() { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - - CB_CONTAINER cb1(10, v.begin(), v.end()); - const CB_CONTAINER cb2(10, v.begin(), v.end()); - - CB_CONTAINER cb3(10); - cb3.push_back(1); - cb3.push_back(2); - cb3.insert(cb3.begin(), 3); - int i = 0; - CB_CONTAINER::const_iterator it = cb3.begin(); - for (; it != cb3.end(); it++) { - i += *it; - } - CB_CONTAINER cb4(20); - const CB_CONTAINER cb5(20); - - BOOST_CHECK(*cb1.begin() == 11); - BOOST_CHECK(*cb2.begin() == 11); - BOOST_CHECK(i == 6); - BOOST_CHECK(cb4.begin() == cb4.end()); - BOOST_CHECK(cb5.begin() == cb5.end()); - - generic_test(cb1); - generic_test(cb3); - generic_test(cb4); -} - -void rbegin_and_rend_test() { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - - CB_CONTAINER cb1(10, v.begin(), v.end()); - const CB_CONTAINER cb2(10, v.begin(), v.end()); - - CB_CONTAINER cb3(3); - cb3.push_back(1); - cb3.push_back(2); - cb3.insert(cb3.begin(), 3); - cb3.push_back(1); - int i = 0; - CB_CONTAINER::reverse_iterator it = cb3.rbegin(); - for (; it != cb3.rend(); it++) { - i += *it; - } - CB_CONTAINER cb4(20); - const CB_CONTAINER cb5(20); - - BOOST_CHECK(*cb1.rbegin() == 13); - BOOST_CHECK(*cb2.rbegin() == 13); - BOOST_CHECK(i == 4); - BOOST_CHECK(cb4.rbegin() == cb4.rend()); - BOOST_CHECK(cb5.rbegin() == cb5.rend()); - - generic_test(cb1); - generic_test(cb3); - generic_test(cb4); -} - -void element_access_and_insert_test() { - - CB_CONTAINER cb(3); - cb.push_back(1); - cb.push_back(2); - cb.insert(cb.begin(), 3); - cb.push_back(4); - const CB_CONTAINER ccb = cb; - - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(ccb[2] == 4); - - generic_test(cb); -} - -void at_test() { - -#if !defined(BOOST_NO_EXCEPTIONS) - - CB_CONTAINER cb(3); - cb.push_back(1); - - try { - BOOST_CHECK(cb.at(0) == 1); - } - catch (out_of_range&) { - BOOST_ERROR("An unexpected exception has been thrown!"); - } - - BOOST_CHECK_THROW(cb.at(2), out_of_range); - - generic_test(cb); - -#endif // #if !defined(BOOST_NO_EXCEPTIONS) -} - -void front_and_back_test() { - - CB_CONTAINER cb(1); - cb.push_back(2); - cb.push_back(3); - - BOOST_CHECK(cb.front() == cb.back()); - BOOST_CHECK(cb.back() == 3); - - generic_test(cb); -} - -void linearize_test() { - - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - v.push_back(6); - v.push_back(7); - v.push_back(8); - v.push_back(9); - v.push_back(10); - v.push_back(11); - v.push_back(12); - CB_CONTAINER cb1(10, v.begin(), v.begin() + 10); - cb1.push_back(11); - cb1.push_back(12); - cb1.push_back(13); - CB_CONTAINER cb2(10, v.begin(), v.begin() + 10); - cb2.push_back(11); - cb2.push_back(12); - cb2.push_back(13); - cb2.push_back(14); - cb2.push_back(15); - cb2.push_back(16); - cb2.push_back(17); - CB_CONTAINER cb3(10, v.begin(), v.begin() + 10); - cb3.push_back(11); - cb3.push_back(12); - cb3.push_back(13); - cb3.pop_front(); - cb3.pop_front(); - CB_CONTAINER cb4(5); - CB_CONTAINER cb5(12, v.begin(), v.end()); - cb5.push_back(13); - cb5.push_back(14); - cb5.push_back(15); - cb5.pop_front(); - cb5.pop_front(); - cb5.pop_front(); - cb5.pop_front(); - cb5.pop_front(); - cb5.pop_front(); - CB_CONTAINER cb6(6); - cb6.push_back(-2); - cb6.push_back(-1); - cb6.push_back(0); - cb6.push_back(1); - cb6.push_back(2); - cb6.push_back(3); - cb6.push_back(4); - cb6.push_back(5); - cb6.push_back(6); - cb6.pop_back(); - - BOOST_CHECK(*cb1.linearize() == 4); - BOOST_CHECK(cb1.linearize() == cb1.array_one().first); - BOOST_CHECK(&cb1[0] < &cb1[1] - && &cb1[1] < &cb1[2] - && &cb1[2] < &cb1[3] - && &cb1[3] < &cb1[4] - && &cb1[4] < &cb1[5] - && &cb1[5] < &cb1[6] - && &cb1[6] < &cb1[7] - && &cb1[7] < &cb1[8] - && &cb1[8] < &cb1[9]); - BOOST_CHECK(*(cb1.linearize() + 1) == 5); - BOOST_CHECK(*(cb1.linearize() + 2) == 6); - BOOST_CHECK(*(cb1.linearize() + 3) == 7); - BOOST_CHECK(*(cb1.linearize() + 4) == 8); - BOOST_CHECK(*(cb1.linearize() + 5) == 9); - BOOST_CHECK(*(cb1.linearize() + 6) == 10); - BOOST_CHECK(*(cb1.linearize() + 7) == 11); - BOOST_CHECK(*(cb1.linearize() + 8) == 12); - BOOST_CHECK(*(cb1.linearize() + 9) == 13); - BOOST_CHECK(*cb2.linearize() == 8); - BOOST_CHECK(&cb2[0] < &cb2[1] - && &cb2[1] < &cb2[2] - && &cb2[2] < &cb2[3] - && &cb2[3] < &cb2[4] - && &cb2[4] < &cb2[5] - && &cb2[5] < &cb2[6] - && &cb2[6] < &cb2[7] - && &cb2[7] < &cb2[8] - && &cb2[8] < &cb2[9]); - BOOST_CHECK(*(cb2.linearize() + 1) == 9); - BOOST_CHECK(*(cb2.linearize() + 2) == 10); - BOOST_CHECK(*(cb2.linearize() + 3) == 11); - BOOST_CHECK(*(cb2.linearize() + 4) == 12); - BOOST_CHECK(*(cb2.linearize() + 5) == 13); - BOOST_CHECK(*(cb2.linearize() + 6) == 14); - BOOST_CHECK(*(cb2.linearize() + 7) == 15); - BOOST_CHECK(*(cb2.linearize() + 8) == 16); - BOOST_CHECK(*(cb2.linearize() + 9) == 17); - BOOST_CHECK(*cb3.linearize() == 6); - BOOST_CHECK(&cb3[0] < &cb3[1] - && &cb3[1] < &cb3[2] - && &cb3[2] < &cb3[3] - && &cb3[3] < &cb3[4] - && &cb3[4] < &cb3[5] - && &cb3[5] < &cb3[6] - && &cb3[6] < &cb3[7]); - BOOST_CHECK(*(cb3.linearize() + 1) == 7); - BOOST_CHECK(*(cb3.linearize() + 2) == 8); - BOOST_CHECK(*(cb3.linearize() + 3) == 9); - BOOST_CHECK(*(cb3.linearize() + 4) == 10); - BOOST_CHECK(*(cb3.linearize() + 5) == 11); - BOOST_CHECK(*(cb3.linearize() + 6) == 12); - BOOST_CHECK(*(cb3.linearize() + 7) == 13); - BOOST_CHECK(cb4.linearize() == 0); - BOOST_CHECK(*cb5.linearize() == 10); - BOOST_CHECK(&cb5[0] < &cb5[1] - && &cb5[1] < &cb5[2] - && &cb5[2] < &cb5[3] - && &cb5[3] < &cb5[4] - && &cb5[4] < &cb5[5]); - BOOST_CHECK(*(cb5.linearize() + 1) == 11); - BOOST_CHECK(*(cb5.linearize() + 2) == 12); - BOOST_CHECK(*(cb5.linearize() + 3) == 13); - BOOST_CHECK(*(cb5.linearize() + 4) == 14); - BOOST_CHECK(*(cb5.linearize() + 5) == 15); - BOOST_CHECK(*cb6.linearize() == 1); - BOOST_CHECK(&cb6[0] < &cb6[1] - && &cb6[1] < &cb6[2] - && &cb6[2] < &cb6[3] - && &cb6[3] < &cb6[4]); - BOOST_CHECK(*(cb6.linearize() + 1) == 2); - BOOST_CHECK(*(cb6.linearize() + 2) == 3); - BOOST_CHECK(*(cb6.linearize() + 3) == 4); - BOOST_CHECK(*(cb6.linearize() + 4) == 5); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); - generic_test(cb5); - generic_test(cb6); -} - -void array_range_test() { - - CB_CONTAINER cb(7); - CB_CONTAINER::array_range a1 = cb.array_one(); - CB_CONTAINER::array_range a2 = cb.array_two(); - CB_CONTAINER::const_array_range ca1 = cb.array_one(); - CB_CONTAINER::const_array_range ca2 = cb.array_two(); - - BOOST_CHECK(a1.second == 0); - BOOST_CHECK(a2.second == 0); - BOOST_CHECK(ca1.second == 0); - BOOST_CHECK(ca2.second == 0); - - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - a1 = cb.array_one(); - a2 = cb.array_two(); - ca1 = cb.array_one(); - ca2 = cb.array_two(); - - BOOST_CHECK(a1.first[0] == 1); - BOOST_CHECK(a1.first[2] == 3); - BOOST_CHECK(ca1.first[0] == 1); - BOOST_CHECK(ca1.first[2] == 3); - BOOST_CHECK(a1.second == 3); - BOOST_CHECK(a2.second == 0); - BOOST_CHECK(ca1.second == 3); - BOOST_CHECK(ca2.second == 0); - - cb.push_back(4); - cb.push_back(5); - cb.push_back(6); - cb.push_back(7); - cb.push_back(8); - cb.push_back(9); - cb.push_back(10); - a1 = cb.array_one(); - a2 = cb.array_two(); - ca1 = cb.array_one(); - ca2 = cb.array_two(); - - BOOST_CHECK(a1.first[0] == 4); - BOOST_CHECK(a1.first[3] == 7); - BOOST_CHECK(a2.first[0] == 8); - BOOST_CHECK(a2.first[2] == 10); - BOOST_CHECK(ca1.first[0] == 4); - BOOST_CHECK(ca1.first[3] == 7); - BOOST_CHECK(ca2.first[0] == 8); - BOOST_CHECK(ca2.first[2] == 10); - BOOST_CHECK(a1.second == 4); - BOOST_CHECK(a2.second == 3); - BOOST_CHECK(ca1.second == 4); - BOOST_CHECK(ca2.second == 3); - - cb.pop_front(); - cb.pop_back(); - a1 = cb.array_one(); - a2 = cb.array_two(); - ca1 = cb.array_one(); - ca2 = cb.array_two(); - - BOOST_CHECK(a1.first[0] == 5); - BOOST_CHECK(a1.first[2] == 7); - BOOST_CHECK(a2.first[0] == 8); - BOOST_CHECK(a2.first[1] == 9); - BOOST_CHECK(ca1.first[0] == 5); - BOOST_CHECK(ca1.first[2] == 7); - BOOST_CHECK(ca2.first[0] == 8); - BOOST_CHECK(ca2.first[1] == 9); - BOOST_CHECK(a1.second == 3); - BOOST_CHECK(a2.second == 2); - BOOST_CHECK(ca1.second == 3); - BOOST_CHECK(ca2.second == 2); - - cb.pop_back(); - cb.pop_back(); - cb.pop_back(); - a1 = cb.array_one(); - a2 = cb.array_two(); - ca1 = cb.array_one(); - ca2 = cb.array_two(); - - BOOST_CHECK(a1.first[0] == 5); - BOOST_CHECK(a1.first[1] == 6); - BOOST_CHECK(ca1.first[0] == 5); - BOOST_CHECK(ca1.first[1] == 6); - BOOST_CHECK(a1.second == 2); - BOOST_CHECK(a2.second == 0); - BOOST_CHECK(ca1.second == 2); - BOOST_CHECK(ca2.second == 0); - - CB_CONTAINER cb0(0); - a1 = cb0.array_one(); - a2 = cb0.array_two(); - - BOOST_CHECK(a1.second == 0); - BOOST_CHECK(a2.second == 0); - - const CB_CONTAINER ccb(10, 1); - ca1 = ccb.array_one(); - ca2 = ccb.array_two(); - - BOOST_CHECK(ca1.second == 10); - BOOST_CHECK(*(ca1.first) == 1); - BOOST_CHECK(ca2.second == 0); - - generic_test(cb); - generic_test(cb0); -} - -void capacity_and_reserve_test() { - - CB_CONTAINER cb1(0); - CB_CONTAINER cb2(10); - - BOOST_CHECK(cb1.capacity() == 0); - BOOST_CHECK(cb1.size() == 0); - BOOST_CHECK(cb1.reserve() == 0); - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1.empty()); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb2.size() == 0); - BOOST_CHECK(cb2.reserve() == 10); - - cb1.push_back(1); - cb2.push_back(2); - cb2.push_back(2); - cb2.push_back(2); - - BOOST_CHECK(cb1.capacity() == 0); - BOOST_CHECK(cb1.size() == 0); - BOOST_CHECK(cb1.reserve() == 0); - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1.empty()); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb2.size() == 3); - BOOST_CHECK(cb2.reserve() == 7); - - generic_test(cb1); - generic_test(cb2); -} - -void full_and_empty_test() { - - CB_CONTAINER cb1(10); - CB_CONTAINER cb2(3); - CB_CONTAINER cb3(2); - CB_CONTAINER cb4(2); - cb2.push_back(1); - cb2.push_back(3); - cb2.push_back(1); - cb2.push_back(1); - cb2.push_back(1); - cb3.push_back(3); - cb3.push_back(1); - cb4.push_back(1); - - BOOST_CHECK(cb1.empty()); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb3.full()); - BOOST_CHECK(!cb4.empty()); - BOOST_CHECK(!cb4.full()); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void set_capacity_test() { - - CB_CONTAINER cb1(10); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(1); - cb1.set_capacity(5); - CB_CONTAINER cb2(3); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(1); - cb2.set_capacity(10); - CB_CONTAINER cb3(5); - cb3.push_back(2); - cb3.push_back(3); - cb3.push_back(1); - cb3.set_capacity(2); - - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1[0] == 2); - BOOST_CHECK(cb1[2] == 1); - BOOST_CHECK(cb1.capacity() == 5); - BOOST_CHECK(cb2.size() == 3); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb2[2] == 1); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3[0] == 2); - BOOST_CHECK(cb3[1] == 3); - BOOST_CHECK(cb3.capacity() == 2); - - cb3.set_capacity(2); - - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3[0] == 2); - BOOST_CHECK(cb3[1] == 3); - BOOST_CHECK(cb3.capacity() == 2); - - cb3.set_capacity(0); - - BOOST_CHECK(cb3.size() == 0); - BOOST_CHECK(cb3.capacity() == 0); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void rset_capacity_test() { - - CB_CONTAINER cb1(10); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(1); - cb1.rset_capacity(5); - CB_CONTAINER cb2(3); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(1); - cb2.rset_capacity(10); - CB_CONTAINER cb3(5); - cb3.push_back(2); - cb3.push_back(3); - cb3.push_back(1); - cb3.rset_capacity(2); - - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1[0] == 2); - BOOST_CHECK(cb1[2] == 1); - BOOST_CHECK(cb1.capacity() == 5); - BOOST_CHECK(cb2.size() == 3); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb2[2] == 1); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3[0] == 3); - BOOST_CHECK(cb3[1] == 1); - BOOST_CHECK(cb3.capacity() == 2); - - cb3.rset_capacity(2); - - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3[0] == 3); - BOOST_CHECK(cb3[1] == 1); - BOOST_CHECK(cb3.capacity() == 2); - - cb3.rset_capacity(0); - - BOOST_CHECK(cb3.size() == 0); - BOOST_CHECK(cb3.capacity() == 0); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void resize_test() { - - CB_CONTAINER cb1(10); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - cb1.resize(20, 5); - CB_CONTAINER cb2(10); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - cb2.resize(2); - CB_CONTAINER cb3(10, 1); - cb3.resize(0); - CB_CONTAINER cb4(10, 1); - cb4.resize(10); - - BOOST_CHECK(cb1.size() == 20); - BOOST_CHECK(cb1.capacity() == 20); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[3] == 4); - BOOST_CHECK(cb1[4] == 5); - BOOST_CHECK(cb1[19] == 5); - BOOST_CHECK(cb2.size() == 2); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 2); - BOOST_CHECK(cb3.size() == 0); - BOOST_CHECK(cb3.capacity() == 10); - BOOST_CHECK(cb4.size() == 10); - BOOST_CHECK(cb4.capacity() == 10); - BOOST_CHECK(cb4[0] == 1); - BOOST_CHECK(cb4[9] == 1); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void rresize_test() { - - CB_CONTAINER cb1(10); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - cb1.rresize(20, 5); - CB_CONTAINER cb2(10); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - cb2.rresize(2); - CB_CONTAINER cb3(10, 1); - cb3.rresize(0); - CB_CONTAINER cb4(10, 1); - cb4.rresize(10); - - BOOST_CHECK(cb1.size() == 20); - BOOST_CHECK(cb1.capacity() == 20); - BOOST_CHECK(cb1[0] == 5); - BOOST_CHECK(cb1[15] == 5); - BOOST_CHECK(cb1[16] == 1); - BOOST_CHECK(cb1[19] == 4); - BOOST_CHECK(cb2.size() == 2); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb2[0] == 3); - BOOST_CHECK(cb2[1] == 4); - BOOST_CHECK(cb3.size() == 0); - BOOST_CHECK(cb3.capacity() == 10); - BOOST_CHECK(cb4.size() == 10); - BOOST_CHECK(cb4.capacity() == 10); - BOOST_CHECK(cb4[0] == 1); - BOOST_CHECK(cb4[9] == 1); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void constructor_test() { - - CB_CONTAINER cb1(3); - CB_CONTAINER cb2(3, 2); - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - CB_CONTAINER cb3(v.begin(), v.end()); - CB_CONTAINER cb4(3, v.begin(), v.end()); - CB_CONTAINER cb5(10, v.begin(), v.end()); - - BOOST_CHECK(cb1.size() == 0); - BOOST_CHECK(cb1.capacity() == 3); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb2[1] == 2); - BOOST_CHECK(cb2[2] == 2); - BOOST_CHECK(cb3.size() == 5); - BOOST_CHECK(cb3.capacity() == 5); - BOOST_CHECK(cb3.full()); - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[4] == 5); - BOOST_CHECK(cb4.size() == 3); - BOOST_CHECK(cb4.capacity() == 3); - BOOST_CHECK(cb4.full()); - BOOST_CHECK(cb4[0] == 3); - BOOST_CHECK(cb4[2] == 5); - BOOST_CHECK(cb5.size() == 5); - BOOST_CHECK(cb5.capacity() == 10); - BOOST_CHECK(!cb5.full()); - BOOST_CHECK(cb5[0] == 1); - BOOST_CHECK(cb5[4] == 5); - - cb5.push_back(6); - - BOOST_CHECK(cb5[5] == 6); - BOOST_CHECK(cb5.size() == 6); - -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - CB_CONTAINER cb6(MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb7(3, MyInputIterator(v.begin()), MyInputIterator(v.end())); - - BOOST_CHECK(cb6.capacity() == 5); - BOOST_CHECK(cb7.capacity() == 3); - -#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); - generic_test(cb5); -} - -void assign_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - cb1.push_back(5); - cb1.assign(3, 8); - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1.capacity() == 3); - BOOST_CHECK(cb1[0] == 8); - BOOST_CHECK(cb1[2] == 8); - - cb1.assign(6, 7); - BOOST_CHECK(cb1.size() == 6); - BOOST_CHECK(cb1.capacity() == 6); - BOOST_CHECK(cb1[0] == 7); - BOOST_CHECK(cb1[5] == 7); - - CB_CONTAINER cb2(4); - cb2.assign(3, 1.1f); - BOOST_CHECK(cb2[0] == 1.1f); - - CB_CONTAINER cb3(5); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - cb3.assign((size_t)10, 1); // The size_t cast is not needed. It is present here just because of testing purposes. - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[9] == 1); - BOOST_CHECK(cb3.size() == 10); - BOOST_CHECK(cb3.capacity() == 10); - -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - - CB_CONTAINER cb4(3); - cb4.assign(MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb5(3); - cb5.assign(4, MyInputIterator(v.begin()), MyInputIterator(v.end())); - - BOOST_CHECK(cb4.capacity() == 5); - BOOST_CHECK(cb5.capacity() == 4); - -#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - generic_test(cb1); - generic_test(cb3); -} - -void copy_constructor_and_assign_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - cb1.push_back(5); - CB_CONTAINER cb2 = cb1; - - BOOST_CHECK(cb1 == cb2); - - CB_CONTAINER cb3(20); - cb1.pop_back(); - CB_CONTAINER cb4(3); - cb3 = cb2; - cb3 = cb3; - cb4 = cb1; - - BOOST_CHECK(cb3 == cb2); - BOOST_CHECK(cb4 == cb1); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb3.full()); - BOOST_CHECK(cb3.capacity() == 4); - BOOST_CHECK(cb4.capacity() == 4); - BOOST_CHECK(!cb4.full()); - BOOST_CHECK(*(cb4.end() - 1) == 4); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void swap_test() { - - CB_CONTAINER cb1(2); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - CB_CONTAINER cb2(5); - cb2.push_back(8); - cb2.swap(cb1); - cb2.swap(cb2); - - BOOST_CHECK(cb2.capacity() == 2); - BOOST_CHECK(cb2[0] == 2); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb1.capacity() == 5); - BOOST_CHECK(cb1[0] == 8); - BOOST_CHECK(cb1.size() == 1); - - generic_test(cb1); - generic_test(cb2); -} - -void push_back_test() { - - CB_CONTAINER cb1(5); - cb1.push_back(); - cb1.push_back(MyDefaultConstructible(2)); - BOOST_CHECK(cb1[0].m_n == 1); - BOOST_CHECK(cb1[1].m_n == 2); - - CB_CONTAINER cb2(5); - cb2.push_back(); - BOOST_CHECK(cb2.back() == CB_CONTAINER::value_type()); - - cb2.push_back(1); - BOOST_CHECK(cb2.back() == 1); - - generic_test(cb2); -} - -void pop_back_test() { - - CB_CONTAINER cb(4); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - cb.pop_back(); - - BOOST_CHECK(cb.size() == 3); - BOOST_CHECK(!cb.full()); - BOOST_CHECK(cb[0] == 2); - - generic_test(cb); -} - -void insert_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - CB_CONTAINER::iterator it1 = cb1.begin() + 1; - it1 = cb1.insert(it1, 10); - CB_CONTAINER cb2(4); - cb2.push_back(1); - cb2.insert(cb2.begin()); - cb2.insert(cb2.begin(), -1); - CB_CONTAINER::iterator it2 = cb2.begin() + 1; - it2 = cb2.insert(it2, 5); - CB_CONTAINER cb3(2); - cb3.insert(cb3.end(), 10); - cb3.insert(cb3.end(), 20); - cb3.insert(cb3.begin(), 30); - cb3.insert(cb3.end(), 40); - - BOOST_CHECK(cb1[1] == 10); - BOOST_CHECK(*it1 == 10); - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb2[1] == 5); - BOOST_CHECK(*it2 == 5); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb3[0] == 20); - BOOST_CHECK(cb3[1] == 40); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void insert_n_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.insert(cb1.begin() + 1, 2, 10); - CB_CONTAINER cb2(2, 3); - cb2.insert(cb2.begin(), 10, 5); - CB_CONTAINER cb3(4); - cb3.insert(cb3.end(), 1, 6); - CB_CONTAINER cb4(6); - cb4.push_back(1); - cb4.push_back(2); - cb4.push_back(3); - cb4.push_back(4); - cb4.insert(cb4.begin() + 2, 5, 6); - cb4.insert(cb4.begin() + 2, 0, 7); - - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1[0] == 10); - BOOST_CHECK(cb1[1] == 10); - BOOST_CHECK(cb1[2] == 2); - BOOST_CHECK(cb1[3] == 3); - BOOST_CHECK(cb2[0] == 3); - BOOST_CHECK(cb2[1] == 3); - BOOST_CHECK(cb3[0] == 6); - BOOST_CHECK(cb3.size() == 1); - BOOST_CHECK(cb4.size() == 6); - BOOST_CHECK(cb4[0] == 6); - BOOST_CHECK(cb4[1] == 6); - BOOST_CHECK(cb4[2] == 6); - BOOST_CHECK(cb4[3] == 6); - BOOST_CHECK(cb4[4] == 3); - BOOST_CHECK(cb4[5] == 4); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void insert_range_test() { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.insert(cb1.begin() + 1, v.begin(), v.end()); - CB_CONTAINER cb2(2, 2); - cb2.insert(cb2.end(), v.begin(), v.end()); - CB_CONTAINER cb3(5); - cb3.insert(cb3.end(), v.end(), v.end()); - CB_CONTAINER cb4(5); - cb4.insert(cb4.end(), v.begin(), v.begin() + 1); - MyInteger array[] = { 5, 6, 7, 8, 9 }; - CB_CONTAINER cb5(6); - cb5.push_back(1); - cb5.push_back(2); - cb5.push_back(3); - cb5.push_back(4); - cb5.insert(cb5.begin() + 2, array, array + 5); - cb5.insert(cb5.begin(), array, array + 5); - - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1[0] == 12); - BOOST_CHECK(cb1[1] == 13); - BOOST_CHECK(cb1[2] == 2); - BOOST_CHECK(cb1[3] == 3); - BOOST_CHECK(cb2[0] == 12); - BOOST_CHECK(cb2[1] == 13); - BOOST_CHECK(cb3.empty()); - BOOST_CHECK(cb4[0] == 11); - BOOST_CHECK(cb4.size() == 1); - BOOST_CHECK(cb5.size() == 6); - BOOST_CHECK(cb5[0] == 6); - BOOST_CHECK(cb5[1] == 7); - BOOST_CHECK(cb5[2] == 8); - BOOST_CHECK(cb5[3] == 9); - BOOST_CHECK(cb5[4] == 3); - BOOST_CHECK(cb5[5] == 4); - -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - v.clear(); - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - - CB_CONTAINER cb6(4); - cb6.push_back(0); - cb6.push_back(-1); - cb6.push_back(-2); - cb6.insert(cb6.begin() + 1, MyInputIterator(v.begin()), MyInputIterator(v.end())); - v.clear(); - v.push_back(11); - v.push_back(12); - v.push_back(13); - CB_CONTAINER cb7(4); - cb7.push_back(1); - cb7.push_back(2); - cb7.push_back(3); - cb7.insert(cb7.begin() + 1, MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb8(2, 2); - cb8.insert(cb8.end(), MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb9(5); - cb9.insert(cb9.end(), MyInputIterator(v.end()), MyInputIterator(v.end())); - CB_CONTAINER cb10(5); - cb10.insert(cb10.end(), MyInputIterator(v.begin()), MyInputIterator(v.begin() + 1)); - v.clear(); - v.push_back(5); - v.push_back(6); - v.push_back(7); - v.push_back(8); - v.push_back(9); - CB_CONTAINER cb11(6); - cb11.push_back(1); - cb11.push_back(2); - cb11.push_back(3); - cb11.push_back(4); - cb11.insert(cb11.begin() + 2, MyInputIterator(v.begin()), MyInputIterator(v.begin() + 5)); - cb11.insert(cb11.begin(), MyInputIterator(v.begin()), MyInputIterator(v.begin() + 5)); - - BOOST_CHECK(cb6.capacity() == 4); - BOOST_CHECK(cb6[0] == 4); - BOOST_CHECK(cb6[3] == -2); - BOOST_CHECK(cb7.full()); - BOOST_CHECK(cb7[0] == 12); - BOOST_CHECK(cb7[1] == 13); - BOOST_CHECK(cb7[2] == 2); - BOOST_CHECK(cb7[3] == 3); - BOOST_CHECK(cb8[0] == 12); - BOOST_CHECK(cb8[1] == 13); - BOOST_CHECK(cb9.empty()); - BOOST_CHECK(cb10[0] == 11); - BOOST_CHECK(cb10.size() == 1); - BOOST_CHECK(cb11.size() == 6); - BOOST_CHECK(cb11[0] == 6); - BOOST_CHECK(cb11[1] == 7); - BOOST_CHECK(cb11[2] == 8); - BOOST_CHECK(cb11[3] == 9); - BOOST_CHECK(cb11[4] == 3); - BOOST_CHECK(cb11[5] == 4); - -#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); - generic_test(cb5); -} - -void push_front_test() { - - CB_CONTAINER cb1(5); - cb1.push_front(); - cb1.push_front(MyDefaultConstructible(2)); - BOOST_CHECK(cb1[0].m_n == 2); - BOOST_CHECK(cb1[1].m_n == 1); - - CB_CONTAINER cb2(5); - cb2.push_front(); - BOOST_CHECK(cb2.front() == CB_CONTAINER::value_type()); - - cb2.push_front(1); - BOOST_CHECK(cb2.front() == 1); - - CB_CONTAINER cb3(0); - cb3.push_front(10); - BOOST_CHECK(cb3.empty()); - - generic_test(cb2); - generic_test(cb3); -} - -void pop_front_test() { - - CB_CONTAINER cb(4); - cb.push_front(1); - cb.push_front(2); - cb.push_front(3); - cb.push_front(4); - cb.push_front(5); - cb.pop_front(); - - BOOST_CHECK(cb.size() == 3); - BOOST_CHECK(!cb.full()); - BOOST_CHECK(cb[0] == 4); - - generic_test(cb); -} - -void rinsert_test() { - - CB_CONTAINER cb1(4); - cb1.push_front(1); - cb1.push_front(2); - cb1.push_front(3); - CB_CONTAINER::iterator it1 = cb1.begin() + 1; - it1 = cb1.rinsert(it1, 10); - CB_CONTAINER cb2(4); - cb2.push_front(1); - cb2.rinsert(cb2.begin()); - cb2.rinsert(cb2.begin(), -1); - CB_CONTAINER::iterator it2 = cb2.end() - 2; - it2 = cb2.rinsert(it2, 5); - CB_CONTAINER cb3(2); - cb3.rinsert(cb3.begin(), 10); - cb3.rinsert(cb3.begin(), 20); - cb3.rinsert(cb3.end(), 30); - cb3.rinsert(cb3.begin(), 40); - CB_CONTAINER cb4(4); - cb4.push_back(1); - cb4.push_back(2); - cb4.push_back(3); - CB_CONTAINER::iterator it3 = cb4.begin() + 1; - it3 = cb4.rinsert(it3, 10); - CB_CONTAINER cb5(4); - cb5.push_back(1); - cb5.rinsert(cb5.begin(), 0); - cb5.rinsert(cb5.begin(), -1); - CB_CONTAINER::iterator it4 = cb5.begin() + 1; - it4 = cb5.rinsert(it4, 5); - CB_CONTAINER cb6(2); - cb6.rinsert(cb6.end(), 10); - cb6.rinsert(cb6.end(), 20); - cb6.rinsert(cb6.begin(), 30); - cb6.rinsert(cb6.end(), 40); - CB_CONTAINER cb7(6); - cb7.push_back(1); - cb7.push_back(2); - cb7.push_back(3); - cb7.push_back(4); - cb7.rinsert(cb7.begin() + 2, 5, 6); - - BOOST_CHECK(cb1[1] == 10); - BOOST_CHECK(*it1 == 10); - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb2[1] == 5); - BOOST_CHECK(*it2 == 5); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb2[3] == 1); - BOOST_CHECK(cb3[0] == 40); - BOOST_CHECK(cb3[1] == 20); - BOOST_CHECK(cb4[1] == 10); - BOOST_CHECK(*it3 == 10); - BOOST_CHECK(cb4.full()); - BOOST_CHECK(cb5[1] == 5); - BOOST_CHECK(*it4 == 5); - BOOST_CHECK(cb5.full()); - BOOST_CHECK(cb6[0] == 30); - BOOST_CHECK(cb6[1] == 10); - BOOST_CHECK(cb7.size() == 6); - BOOST_CHECK(cb7[0] == 1); - BOOST_CHECK(cb7[1] == 2); - BOOST_CHECK(cb7[2] == 6); - BOOST_CHECK(cb7[3] == 6); - BOOST_CHECK(cb7[4] == 6); - BOOST_CHECK(cb7[5] == 6); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); - generic_test(cb5); - generic_test(cb6); - generic_test(cb7); -} - -void rinsert_n_test() { - - CB_CONTAINER cb1(4); - cb1.push_front(1); - cb1.push_front(2); - cb1.push_front(3); - cb1.rinsert(cb1.begin() + 1, 2, 10); - CB_CONTAINER cb2(2, 3); - cb2.rinsert(cb2.begin(), 10, 5); - CB_CONTAINER cb3(4); - cb3.rinsert(cb3.end(), 1, 6); - CB_CONTAINER cb4(4); - cb4.push_back(1); - cb4.push_back(2); - cb4.push_back(3); - cb4.rinsert(cb4.begin() + 1, 2, 10); - MyInteger array[] = { 5, 6, 7, 8, 9 }; - CB_CONTAINER cb5(6); - cb5.push_back(1); - cb5.push_back(2); - cb5.push_back(3); - cb5.push_back(4); - cb5.rinsert(cb5.begin() + 2, array, array + 5); - cb5.rinsert(cb5.end(), array, array + 5); - - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1[0] == 3); - BOOST_CHECK(cb1[1] == 10); - BOOST_CHECK(cb1[2] == 10); - BOOST_CHECK(cb1[3] == 2); - BOOST_CHECK(cb2[0] == 5); - BOOST_CHECK(cb2[1] == 5); - BOOST_CHECK(cb3[0] == 6); - BOOST_CHECK(cb3.size() == 1); - BOOST_CHECK(cb4.full()); - BOOST_CHECK(cb4[0] == 1); - BOOST_CHECK(cb4[1] == 10); - BOOST_CHECK(cb4[2] == 10); - BOOST_CHECK(cb4[3] == 2); - BOOST_CHECK(cb5.size() == 6); - BOOST_CHECK(cb5[0] == 1); - BOOST_CHECK(cb5[1] == 2); - BOOST_CHECK(cb5[2] == 5); - BOOST_CHECK(cb5[3] == 6); - BOOST_CHECK(cb5[4] == 7); - BOOST_CHECK(cb5[5] == 8); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); - generic_test(cb5); -} - -void rinsert_range_test() { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - v.push_back(14); - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.rinsert(cb1.begin() + 1, v.begin(), v.end()); - CB_CONTAINER cb2(2, 2); - cb2.rinsert(cb2.begin(), v.begin(), v.end()); - CB_CONTAINER cb3(5); - cb3.rinsert(cb3.begin(), v.end(), v.end()); - CB_CONTAINER cb4(5); - cb4.rinsert(cb4.begin(), v.begin(), v.begin() + 1); - - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 11); - BOOST_CHECK(cb1[2] == 12); - BOOST_CHECK(cb1[3] == 13); - BOOST_CHECK(cb2[0] == 11); - BOOST_CHECK(cb2[1] == 12); - BOOST_CHECK(cb3.empty()); - BOOST_CHECK(cb4[0] == 11); - BOOST_CHECK(cb4.size() == 1); - -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - v.clear(); - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - - CB_CONTAINER cb10(4); - cb10.push_back(0); - cb10.push_back(-1); - cb10.push_back(-2); - cb10.rinsert(cb10.begin() + 1, MyInputIterator(v.begin()), MyInputIterator(v.end())); - v.clear(); - v.push_back(11); - v.push_back(12); - v.push_back(13); - v.push_back(14); - CB_CONTAINER cb11(4); - cb11.push_back(1); - cb11.push_back(2); - cb11.push_back(3); - cb11.rinsert(cb11.begin() + 1, MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb12(2, 2); - cb12.rinsert(cb12.begin(), MyInputIterator(v.begin()), MyInputIterator(v.end())); - CB_CONTAINER cb13(5); - cb13.rinsert(cb13.begin(), MyInputIterator(v.end()), MyInputIterator(v.end())); - CB_CONTAINER cb14(5); - cb14.rinsert(cb14.begin(), MyInputIterator(v.begin()), MyInputIterator(v.begin() + 1)); - - BOOST_CHECK(cb10.capacity() == 4); - BOOST_CHECK(cb10[0] == 0); - BOOST_CHECK(cb10[3] == 3); - BOOST_CHECK(cb11.full()); - BOOST_CHECK(cb11[0] == 1); - BOOST_CHECK(cb11[1] == 11); - BOOST_CHECK(cb11[2] == 12); - BOOST_CHECK(cb11[3] == 13); - BOOST_CHECK(cb12[0] == 11); - BOOST_CHECK(cb12[1] == 12); - BOOST_CHECK(cb13.empty()); - BOOST_CHECK(cb14[0] == 11); - BOOST_CHECK(cb14.size() == 1); - -#endif // #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void erase_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - CB_CONTAINER::iterator it1 = cb1.erase(cb1.begin() + 1); - - CB_CONTAINER cb2(1, 1); - CB_CONTAINER::iterator it2 = cb2.erase(cb2.begin()); - - CB_CONTAINER cb3(4); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - CB_CONTAINER::iterator it3 = cb3.erase(cb3.begin() + 2); - - BOOST_CHECK(cb1.size() == 2); - BOOST_CHECK(cb1.capacity() == 4); - BOOST_CHECK(*it1 == 3); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 3); - BOOST_CHECK(cb2.size() == 0); - BOOST_CHECK(cb2.capacity() == 1); - BOOST_CHECK(it2 == cb2.end()); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3.capacity() == 4); - BOOST_CHECK(it3 == cb3.end()); - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[1] == 2); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void erase_range_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - CB_CONTAINER::iterator it1 = cb1.erase(cb1.begin() + 1, cb1.begin() + 3); - - CB_CONTAINER cb2(4); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - CB_CONTAINER::iterator it2 = cb2.erase(cb2.begin(), cb2.begin()); - - CB_CONTAINER cb3(4); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - cb3.push_back(4); - CB_CONTAINER::iterator it3 = cb3.erase(cb3.begin() + 2, cb3.end()); - - CB_CONTAINER cb4(10, 1); - CB_CONTAINER::iterator it4 = cb4.erase(cb4.begin(), cb4.end()); - - BOOST_CHECK(cb1.size() == 2); - BOOST_CHECK(cb1.capacity() == 4); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 4); - BOOST_CHECK(*it1 == 4); - BOOST_CHECK(cb2.size() == 4); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[3] == 4); - BOOST_CHECK(*it2 == 1); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3.capacity() == 4); - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[1] == 2); - BOOST_CHECK(it3 == cb3.end()); - BOOST_CHECK(cb4.size() == 0); - BOOST_CHECK(cb4.capacity() == 10); - BOOST_CHECK(it4 == cb4.end()); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void rerase_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - CB_CONTAINER::iterator it1 = cb1.rerase(cb1.begin() + 1); - - CB_CONTAINER cb2(1, 1); - CB_CONTAINER::iterator it2 = cb2.rerase(cb2.begin()); - - CB_CONTAINER cb3(4); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - CB_CONTAINER::iterator it3 = cb3.rerase(cb3.begin()); - - BOOST_CHECK(cb1.size() == 2); - BOOST_CHECK(cb1.capacity() == 4); - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 3); - BOOST_CHECK(cb2.size() == 0); - BOOST_CHECK(cb2.capacity() == 1); - BOOST_CHECK(it2 == cb2.begin()); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3.capacity() == 4); - BOOST_CHECK(it3 == cb3.begin()); - BOOST_CHECK(*it3 == 2); - BOOST_CHECK(cb3[0] == 2); - BOOST_CHECK(cb3[1] == 3); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); -} - -void rerase_range_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - CB_CONTAINER::iterator it1 = cb1.rerase(cb1.begin() + 1, cb1.begin() + 3); - - CB_CONTAINER cb2(4); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - CB_CONTAINER::iterator it2 = cb2.rerase(cb2.begin(), cb2.begin()); - - CB_CONTAINER cb3(4); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - cb3.push_back(4); - CB_CONTAINER::iterator it3 = cb3.rerase(cb3.begin(), cb3.begin() + 2); - - CB_CONTAINER cb4(10, 1); - CB_CONTAINER::iterator it4 = cb4.rerase(cb4.begin(), cb4.end()); - - BOOST_CHECK(cb1.size() == 2); - BOOST_CHECK(cb1.capacity() == 4); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 4); - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(cb2.size() == 4); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[3] == 4); - BOOST_CHECK(*it2 == 1); - BOOST_CHECK(cb3.size() == 2); - BOOST_CHECK(cb3.capacity() == 4); - BOOST_CHECK(cb3[0] == 3); - BOOST_CHECK(cb3[1] == 4); - BOOST_CHECK(it3 == cb3.begin()); - BOOST_CHECK(cb4.size() == 0); - BOOST_CHECK(cb4.capacity() == 10); - BOOST_CHECK(it4 == cb4.begin()); - - generic_test(cb1); - generic_test(cb2); - generic_test(cb3); - generic_test(cb4); -} - -void clear_test() { - - CB_CONTAINER cb(4); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.clear(); - - BOOST_CHECK(cb.empty()); - - generic_test(cb); -} - -void equality_test() { - - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - CB_CONTAINER cb2(10); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - - BOOST_CHECK(cb1 == cb2); - BOOST_CHECK(!(cb2 != cb1)); - - generic_test(cb1); - generic_test(cb2); -} - -void lexicographical_comparison_test() { - - CB_CONTAINER cb1(10); - cb1.push_back('a'); - cb1.push_back('d'); - cb1.push_back('a'); - cb1.push_back('m'); - CB_CONTAINER cb2(5); - cb2.push_back('j'); - cb2.push_back('o'); - cb2.push_back('h'); - cb2.push_back('n'); - - BOOST_CHECK(cb2 > cb1); - BOOST_CHECK(cb1 < cb2); -} - -void assign_range_test() { - - vector v; - v.push_back(11); - v.push_back(12); - v.push_back(13); - CB_CONTAINER cb1(4); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - cb1.assign(v.begin() + 1, v.end()); - CB_CONTAINER cb2(2); - cb2.push_back(1); - cb2.push_back(2); - cb2.assign(v.begin(), v.end()); - - BOOST_CHECK(cb1.capacity() == 2); - BOOST_CHECK(cb1[0] == 12); - BOOST_CHECK(cb1[1] == 13); - BOOST_CHECK(cb2.full()); - BOOST_CHECK(cb2.capacity() == 3); - BOOST_CHECK(cb2[0] == 11); - BOOST_CHECK(cb2[1] == 12); - BOOST_CHECK(cb2[2] == 13); - BOOST_CHECK(cb2.size() == (size_t)distance(v.begin(), v.end())); - - generic_test(cb1); - generic_test(cb2); -} - -// test of the example (introduced in the documentation) -void example_test() { - - CB_CONTAINER cb1(3); - cb1.push_back(1); - cb1.push_back(2); - - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 2); - BOOST_CHECK(!cb1.full()); - BOOST_CHECK(cb1.size() == 2); - BOOST_CHECK(cb1.capacity() == 3); - - cb1.push_back(3); - cb1.push_back(4); - int sum = accumulate(cb1.begin(), cb1.end(), 0); - - BOOST_CHECK(cb1[0] == 2); - BOOST_CHECK(cb1[1] == 3); - BOOST_CHECK(cb1[2] == 4); - BOOST_CHECK(*cb1.begin() == 2); - BOOST_CHECK(cb1.front() == 2); - BOOST_CHECK(cb1.back() == 4); - BOOST_CHECK(sum == 9); - BOOST_CHECK(cb1.full()); - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1.capacity() == 3); - - CB_CONTAINER cb2(5, 1); - cb2.insert(cb2.begin(), 2); - - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 1); - BOOST_CHECK(cb2[2] == 1); - BOOST_CHECK(cb2[3] == 1); - BOOST_CHECK(cb2[4] == 1); - - vector v; - v.push_back(100); - v.push_back(200); - v.push_back(300); - cb2.insert(cb2.begin() + 1, v.begin(), v.end()); - - BOOST_CHECK(cb2[0] == 300); - BOOST_CHECK(cb2[1] == 1); - BOOST_CHECK(cb2[2] == 1); - BOOST_CHECK(cb2[3] == 1); - BOOST_CHECK(cb2[4] == 1); - - CB_CONTAINER cb3(3); - cb3.push_back(1); - cb3.push_back(2); - cb3.push_back(3); - - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3[1] == 2); - BOOST_CHECK(cb3[2] == 3); - - cb3.push_back(4); - cb3.push_back(5); - - BOOST_CHECK(cb3[0] == 3); - BOOST_CHECK(cb3[1] == 4); - BOOST_CHECK(cb3[2] == 5); - - cb3.pop_back(); - cb3.pop_front(); - - BOOST_CHECK(cb3[0] == 4); -} - -void element_destruction_test() { - - CB_CONTAINER cb(5); - cb.push_back(InstanceCounter()); - cb.push_back(InstanceCounter()); - cb.push_back(InstanceCounter()); - int prevCount = InstanceCounter::count(); - cb.clear(); - - BOOST_CHECK(cb.empty()); - BOOST_CHECK(prevCount == 3); - BOOST_CHECK(InstanceCounter::count() == 0); -} - -void const_methods_test() { - - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - const CB_CONTAINER cb(5, v.begin(), v.end()); - - BOOST_CHECK(*cb.begin() == 1); - BOOST_CHECK(*(cb.end() - 1) == 5); - BOOST_CHECK(*cb.rbegin() == 5); - BOOST_CHECK(*(cb.rend() - 1) == 1); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb.at(1) == 2); - BOOST_CHECK(cb.front() == 1); - BOOST_CHECK(cb.back() == 5); -} - -int MyInteger::ms_exception_trigger = 0; -int InstanceCounter::ms_count = 0; - -// add common tests into a test suite -void add_common_tests(test_suite* tests) { - tests->add(BOOST_TEST_CASE(&basic_test)); - tests->add(BOOST_TEST_CASE(&constructor_and_element_access_test)); - tests->add(BOOST_TEST_CASE(&size_test)); - tests->add(BOOST_TEST_CASE(&allocator_test)); - tests->add(BOOST_TEST_CASE(&begin_and_end_test)); - tests->add(BOOST_TEST_CASE(&rbegin_and_rend_test)); - tests->add(BOOST_TEST_CASE(&element_access_and_insert_test)); - tests->add(BOOST_TEST_CASE(&at_test)); - tests->add(BOOST_TEST_CASE(&front_and_back_test)); - tests->add(BOOST_TEST_CASE(&linearize_test)); - tests->add(BOOST_TEST_CASE(&array_range_test)); - tests->add(BOOST_TEST_CASE(&capacity_and_reserve_test)); - tests->add(BOOST_TEST_CASE(&full_and_empty_test)); - tests->add(BOOST_TEST_CASE(&set_capacity_test)); - tests->add(BOOST_TEST_CASE(&rset_capacity_test)); - tests->add(BOOST_TEST_CASE(&resize_test)); - tests->add(BOOST_TEST_CASE(&rresize_test)); - tests->add(BOOST_TEST_CASE(&constructor_test)); - tests->add(BOOST_TEST_CASE(&assign_test)); - tests->add(BOOST_TEST_CASE(©_constructor_and_assign_test)); - tests->add(BOOST_TEST_CASE(&swap_test)); - tests->add(BOOST_TEST_CASE(&push_back_test)); - tests->add(BOOST_TEST_CASE(&pop_back_test)); - tests->add(BOOST_TEST_CASE(&insert_test)); - tests->add(BOOST_TEST_CASE(&insert_n_test)); - tests->add(BOOST_TEST_CASE(&insert_range_test)); - tests->add(BOOST_TEST_CASE(&push_front_test)); - tests->add(BOOST_TEST_CASE(&pop_front_test)); - tests->add(BOOST_TEST_CASE(&rinsert_test)); - tests->add(BOOST_TEST_CASE(&rinsert_n_test)); - tests->add(BOOST_TEST_CASE(&rinsert_range_test)); - tests->add(BOOST_TEST_CASE(&erase_test)); - tests->add(BOOST_TEST_CASE(&erase_range_test)); - tests->add(BOOST_TEST_CASE(&rerase_test)); - tests->add(BOOST_TEST_CASE(&rerase_range_test)); - tests->add(BOOST_TEST_CASE(&clear_test)); - tests->add(BOOST_TEST_CASE(&equality_test)); - tests->add(BOOST_TEST_CASE(&lexicographical_comparison_test)); - tests->add(BOOST_TEST_CASE(&assign_range_test)); - tests->add(BOOST_TEST_CASE(&example_test)); - tests->add(BOOST_TEST_CASE(&element_destruction_test)); - tests->add(BOOST_TEST_CASE(&const_methods_test)); -} diff --git a/test/soft_iterator_invalidation.cpp b/test/soft_iterator_invalidation.cpp deleted file mode 100644 index b05e7cd..0000000 --- a/test/soft_iterator_invalidation.cpp +++ /dev/null @@ -1,747 +0,0 @@ -// Demonstration of rules when an iterator is considered to be valid if the soft -// iterator invalidation definition is applied. -// Note: The soft iterator invalidation definition CAN NOT be applied -// to the space optimized circular buffer. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_CB_DISABLE_DEBUG - -#include "test.hpp" - -// test of the example (introduced in the documentation) -void validity_example_test() { - - circular_buffer cb(3); - - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - circular_buffer::iterator it = cb.begin(); - - BOOST_CHECK(*it == 1); - - cb.push_back(4); - - BOOST_CHECK(*it == 4); -} - -void validity_insert_test() { - - int array[] = { 1, 2, 3 }; - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(4, array, array + 3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.insert(cb.begin() + 1, 4); - - // memory placement: { 1, 4, 2, 3 } - // circular buffer: { 1, 4, 2, 3 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 4); - BOOST_CHECK(*it3 == 2); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 4); - BOOST_CHECK(cb[2] == 2); - BOOST_CHECK(cb[3] == 3); - - // it4 -> 3 - circular_buffer::iterator it4 = it1 + 3; - - cb.insert(cb.begin() + 1, 5); - - // memory placement: { 3, 5, 4, 2 } - // circular buffer: { 5, 4, 2, 3 } - BOOST_CHECK(*it1 == 3); - BOOST_CHECK(*it2 == 5); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(*it4 == 2); - BOOST_CHECK(cb[0] == 5); - BOOST_CHECK(cb[1] == 4); - BOOST_CHECK(cb[2] == 2); - BOOST_CHECK(cb[3] == 3); -} - -void validity_insert_n_test() { - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(5); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.insert(cb.begin() + 1, 2, 4); - - // memory placement: { 1, 4, 4, 2, 3 } - // circular buffer: { 1, 4, 4, 2, 3 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 4); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 4); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 2); - BOOST_CHECK(cb[4] == 3); - - // it4 -> 2, it5 -> 3 - circular_buffer::iterator it4 = it1 + 3; - circular_buffer::iterator it5 = it1 + 4; - - cb.insert(cb.begin() + 1, 2, 5); - - // memory placement: { 3, 5, 4, 4, 2 } - 5 inserted only once - // circular buffer: { 5, 4, 4, 2, 3 } - BOOST_CHECK(*it1 == 3); - BOOST_CHECK(*it2 == 5); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(*it4 == 4); - BOOST_CHECK(*it5 == 2); - BOOST_CHECK(cb[0] == 5); - BOOST_CHECK(cb[1] == 4); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 2); - BOOST_CHECK(cb[4] == 3); -} - -void validity_insert_range_test() { - - vector v1; - v1.push_back(4); - v1.push_back(5); - - vector v2; - v2.push_back(6); - v2.push_back(7); - - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb1(5); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - - // it11 -> 1, it12 -> 2, it13 -> 3 - circular_buffer::iterator it11 = cb1.begin(); - circular_buffer::iterator it12 = cb1.begin() + 1; - circular_buffer::iterator it13 = cb1.begin() + 2; - - cb1.insert(cb1.begin() + 1, v1.begin(), v1.end()); - - // memory placement: { 1, 4, 5, 2, 3 } - // circular buffer: { 1, 4, 5, 2, 3 } - BOOST_CHECK(*it11 == 1); - BOOST_CHECK(*it12 == 4); - BOOST_CHECK(*it13 == 5); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 4); - BOOST_CHECK(cb1[2] == 5); - BOOST_CHECK(cb1[3] == 2); - BOOST_CHECK(cb1[4] == 3); - - // it14 -> 2, it15 -> 3 - circular_buffer::iterator it14 = it11 + 3; - circular_buffer::iterator it15 = it11 + 4; - - cb1.insert(cb1.begin() + 1, v2.begin(), v2.end()); - - // memory placement: { 3, 7, 4, 5, 2 } - 7 inserted only - // circular buffer: { 7, 4, 5, 2, 3 } - BOOST_CHECK(*it11 == 3); - BOOST_CHECK(*it12 == 7); - BOOST_CHECK(*it13 == 4); - BOOST_CHECK(*it14 == 5); - BOOST_CHECK(*it15 == 2); - BOOST_CHECK(cb1[0] == 7); - BOOST_CHECK(cb1[1] == 4); - BOOST_CHECK(cb1[2] == 5); - BOOST_CHECK(cb1[3] == 2); - BOOST_CHECK(cb1[4] == 3); - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb2(5); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - - // it21 -> 1, it22 -> 2, it23 -> 3 - circular_buffer::iterator it21 = cb2.begin(); - circular_buffer::iterator it22 = cb2.begin() + 1; - circular_buffer::iterator it23 = cb2.begin() + 2; - - cb2.insert(cb2.begin() + 1, MyInputIterator(v1.begin()), MyInputIterator(v1.end())); - - // memory placement: { 1, 4, 5, 2, 3 } - // circular buffer: { 1, 4, 5, 2, 3 } - BOOST_CHECK(*it21 == 1); - BOOST_CHECK(*it22 == 4); - BOOST_CHECK(*it23 == 5); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 4); - BOOST_CHECK(cb2[2] == 5); - BOOST_CHECK(cb2[3] == 2); - BOOST_CHECK(cb2[4] == 3); - - // it24 -> 2, it25 -> 3 - circular_buffer::iterator it24 = it21 + 3; - circular_buffer::iterator it25 = it21 + 4; - - cb2.insert(cb2.begin() + 1, MyInputIterator(v2.begin()), MyInputIterator(v2.end())); - - // memory placement: { 2, 3, 7, 4, 5 } - using input iterator inserts all items even if they are later replaced - // circular buffer: { 7, 4, 5, 2, 3 } - BOOST_CHECK(*it21 == 2); - BOOST_CHECK(*it22 == 3); - BOOST_CHECK(*it23 == 7); - BOOST_CHECK(*it24 == 4); - BOOST_CHECK(*it25 == 5); - BOOST_CHECK(cb2[0] == 7); - BOOST_CHECK(cb2[1] == 4); - BOOST_CHECK(cb2[2] == 5); - BOOST_CHECK(cb2[3] == 2); - BOOST_CHECK(cb2[4] == 3); -} - -void validity_rinsert_test() { - - int array[] = { 1, 2, 3 }; - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(4, array, array + 3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.rinsert(cb.begin() + 2, 4); - - // memory placement: { 2, 4, 3, 1 } - // circular buffer: { 1, 2, 4, 3 } - BOOST_CHECK(*it1 == 2); - BOOST_CHECK(*it2 == 4); - BOOST_CHECK(*it3 == 3); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 3); - - // it4 -> 1 - circular_buffer::iterator it4 = it1 - 1; - - cb.rinsert(cb.begin() + 2, 5); - - // memory placement: { 5, 4, 1, 2 } - // circular buffer: { 1, 2, 5, 4 } - BOOST_CHECK(*it1 == 5); - BOOST_CHECK(*it2 == 4); - BOOST_CHECK(*it3 == 1); - BOOST_CHECK(*it4 == 2); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 5); - BOOST_CHECK(cb[3] == 4); -} - -void validity_rinsert_n_test() { - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(5); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.rinsert(cb.begin() + 2, 2, 4); - - // memory placement: { 4, 4, 3, 1, 2 } - // circular buffer: { 1, 2, 4, 4, 3 } - BOOST_CHECK(*it1 == 4); - BOOST_CHECK(*it2 == 4); - BOOST_CHECK(*it3 == 3); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 4); - BOOST_CHECK(cb[4] == 3); - - // it4 -> 1, it5 -> 2 - circular_buffer::iterator it4 = it1 - 2; - circular_buffer::iterator it5 = it1 - 1; - - cb.rinsert(cb.begin() + 4, 2, 5); - - // memory placement: { 4, 5, 1, 2, 4 } - 5 inserted only once - // circular buffer: { 1, 2, 4, 4, 5 } - BOOST_CHECK(*it1 == 4); - BOOST_CHECK(*it2 == 5); - BOOST_CHECK(*it3 == 1); - BOOST_CHECK(*it4 == 2); - BOOST_CHECK(*it5 == 4); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 4); - BOOST_CHECK(cb[4] == 5); -} - -void validity_rinsert_range_test() { - - vector v1; - v1.push_back(4); - v1.push_back(5); - - vector v2; - v2.push_back(6); - v2.push_back(7); - - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb1(5); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it11 = cb1.begin(); - circular_buffer::iterator it12 = cb1.begin() + 1; - circular_buffer::iterator it13 = cb1.begin() + 2; - - cb1.rinsert(cb1.begin() + 2, v1.begin(), v1.end()); - - // memory placement: { 4, 5, 3, 1, 2 } - // circular buffer: { 1, 2, 4, 5, 3 } - BOOST_CHECK(*it11 == 4); - BOOST_CHECK(*it12 == 5); - BOOST_CHECK(*it13 == 3); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 2); - BOOST_CHECK(cb1[2] == 4); - BOOST_CHECK(cb1[3] == 5); - BOOST_CHECK(cb1[4] == 3); - - // it14 -> 1, it15 -> 2 - circular_buffer::iterator it14 = it11 - 2; - circular_buffer::iterator it15 = it11 - 1; - - cb1.rinsert(cb1.begin() + 4, v2.begin(), v2.end()); - - // memory placement: { 5, 6, 1, 2, 4 } - 6 inserted only - // circular buffer: { 1, 2, 4, 5, 6 } - BOOST_CHECK(*it11 == 5); - BOOST_CHECK(*it12 == 6); - BOOST_CHECK(*it13 == 1); - BOOST_CHECK(*it14 == 2); - BOOST_CHECK(*it15 == 4); - BOOST_CHECK(cb1[0] == 1); - BOOST_CHECK(cb1[1] == 2); - BOOST_CHECK(cb1[2] == 4); - BOOST_CHECK(cb1[3] == 5); - BOOST_CHECK(cb1[4] == 6); - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb2(5); - cb2.push_back(1); - cb2.push_back(2); - cb2.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it21 = cb2.begin(); - circular_buffer::iterator it22 = cb2.begin() + 1; - circular_buffer::iterator it23 = cb2.begin() + 2; - - cb2.rinsert(cb2.begin() + 2, MyInputIterator(v1.begin()), MyInputIterator(v1.end())); - - // memory placement: { 4, 5, 3, 1, 2 } - // circular buffer: { 1, 2, 4, 5, 3 } - BOOST_CHECK(*it21 == 4); - BOOST_CHECK(*it22 == 5); - BOOST_CHECK(*it23 == 3); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 2); - BOOST_CHECK(cb2[2] == 4); - BOOST_CHECK(cb2[3] == 5); - BOOST_CHECK(cb2[4] == 3); - - // it24 -> 1, it25 -> 2 - circular_buffer::iterator it24 = it21 - 2; - circular_buffer::iterator it25 = it21 - 1; - - cb2.rinsert(cb2.begin() + 4, MyInputIterator(v2.begin()), MyInputIterator(v2.end())); - - // memory placement: { 5, 6, 1, 2, 4 } - // circular buffer: { 1, 2, 4, 5, 6 } - BOOST_CHECK(*it21 == 5); - BOOST_CHECK(*it22 == 6); - BOOST_CHECK(*it23 == 1); - BOOST_CHECK(*it24 == 2); - BOOST_CHECK(*it25 == 4); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 2); - BOOST_CHECK(cb2[2] == 4); - BOOST_CHECK(cb2[3] == 5); - BOOST_CHECK(cb2[4] == 6); -} - -void validity_erase_test() { - - // memory placement: { 4, 5, 1, 2, 3 } - // circular buffer: { 1, 2, 3, 4, 5 } - circular_buffer cb(5); - cb.push_back(-1); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - - // it1 -> 1, it2 -> 2, it3 -> 3, it4 -> 4 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - circular_buffer::iterator it4 = cb.begin() + 3; - - cb.erase(cb.begin() + 1); - - // memory placement: { 5, X, 1, 3, 4 } - // circular buffer: { 1, 3, 4, 5 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 3); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(*it4 == 5); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 3); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 5); -} - -void validity_erase_range_test() { - - // memory placement: { 4, 5, 6, 1, 2, 3 } - // circular buffer: { 1, 2, 3, 4, 5, 6 } - circular_buffer cb(6); - cb.push_back(-2); - cb.push_back(-1); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - cb.push_back(6); - - // it1 -> 1, it2 -> 2, it3 -> 3, it4 -> 4 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - circular_buffer::iterator it4 = cb.begin() + 3; - - cb.erase(cb.begin() + 2, cb.begin() + 4); - - // memory placement: { 6, X, X, 1, 2, 5 } - // circular buffer: { 1, 2, 5, 6 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 2); - BOOST_CHECK(*it3 == 5); - BOOST_CHECK(*it4 == 6); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 5); - BOOST_CHECK(cb[3] == 6); -} - -void validity_rerase_test() { - - // memory placement: { 4, 5, 1, 2, 3 } - // circular buffer: { 1, 2, 3, 4, 5 } - circular_buffer cb(5); - cb.push_back(-1); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - - // it1 -> 2, it2 -> 3, it3 -> 4, it4 -> 5 - circular_buffer::iterator it1 = cb.begin() + 1; - circular_buffer::iterator it2 = cb.begin() + 2; - circular_buffer::iterator it3 = cb.begin() + 3; - circular_buffer::iterator it4 = cb.begin() + 4; - - cb.rerase(cb.begin() + 1); - - // memory placement: { 4, 5, X, 1, 3 } - // circular buffer: { 1, 3, 4, 5 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 3); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(*it4 == 5); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 3); - BOOST_CHECK(cb[2] == 4); - BOOST_CHECK(cb[3] == 5); -} - -void validity_rerase_range_test() { - - // memory placement: { 4, 5, 6, 1, 2, 3 } - // circular buffer: { 1, 2, 3, 4, 5, 6 } - circular_buffer cb(6); - cb.push_back(-2); - cb.push_back(-1); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - cb.push_back(4); - cb.push_back(5); - cb.push_back(6); - - // it1 -> 3, it2 -> 4, it3 -> 5, it4 -> 6 - circular_buffer::iterator it1 = cb.begin() + 2; - circular_buffer::iterator it2 = cb.begin() + 3; - circular_buffer::iterator it3 = cb.begin() + 4; - circular_buffer::iterator it4 = cb.begin() + 5; - - cb.rerase(cb.begin() + 2, cb.begin() + 4); - - // memory placement: { 2, 5, 6, X, X, 1 } - // circular buffer: { 1, 2, 5, 6 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 2); - BOOST_CHECK(*it3 == 5); - BOOST_CHECK(*it4 == 6); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 5); - BOOST_CHECK(cb[3] == 6); -} - -void validity_linearize_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(3); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.linearize(); - - // memory placement: { 1, 2, 3 } - // circular buffer: { 1, 2, 3 } - BOOST_CHECK(*it1 == 2); - BOOST_CHECK(*it2 == 3); - BOOST_CHECK(*it3 == 1); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); - BOOST_CHECK(cb[2] == 3); -} - -void validity_swap_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb1(3); - cb1.push_back(0); - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - - // it11 -> 1, it12 -> 2, it13 -> 3 - circular_buffer::iterator it11 = cb1.begin(); - circular_buffer::iterator it12 = cb1.begin() + 1; - circular_buffer::iterator it13 = cb1.begin() + 2; - - // memory placement: { 4, 5, 6 } - // circular buffer: { 4, 5, 6 } - circular_buffer cb2(5); - cb2.push_back(4); - cb2.push_back(5); - cb2.push_back(6); - - // it21 -> 4, it22 -> 5, it23 -> 6 - circular_buffer::iterator it21 = cb2.begin(); - circular_buffer::iterator it22 = cb2.begin() + 1; - circular_buffer::iterator it23 = cb2.begin() + 2; - - cb1.swap(cb2); - - // Although iterators refer to the original elements, - // their interal state is inconsistent and no other operation - // (except dereferencing) can be invoked on them any more. - BOOST_CHECK(*it11 == 1); - BOOST_CHECK(*it12 == 2); - BOOST_CHECK(*it13 == 3); - BOOST_CHECK(*it21 == 4); - BOOST_CHECK(*it22 == 5); - BOOST_CHECK(*it23 == 6); - BOOST_CHECK(cb1[0] == 4); - BOOST_CHECK(cb1[1] == 5); - BOOST_CHECK(cb1[2] == 6); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2[1] == 2); - BOOST_CHECK(cb2[2] == 3); -} - -void validity_push_back_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(3); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.push_back(4); - - // memory placement: { 3, 4, 2 } - // circular buffer: { 2, 3, 4 } - BOOST_CHECK(*it1 == 4); - BOOST_CHECK(*it2 == 2); - BOOST_CHECK(*it3 == 3); - BOOST_CHECK(cb[0] == 2); - BOOST_CHECK(cb[1] == 3); - BOOST_CHECK(cb[2] == 4); -} - -void validity_push_front_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(3); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2, it3 -> 3 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - circular_buffer::iterator it3 = cb.begin() + 2; - - cb.push_front(4); - - // memory placement: { 4, 1, 2 } - // circular buffer: { 4, 1, 2 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 2); - BOOST_CHECK(*it3 == 4); - BOOST_CHECK(cb[0] == 4); - BOOST_CHECK(cb[1] == 1); - BOOST_CHECK(cb[2] == 2); -} - -void validity_pop_back_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(3); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 1, it2 -> 2 - circular_buffer::iterator it1 = cb.begin(); - circular_buffer::iterator it2 = cb.begin() + 1; - - cb.pop_back(); - - // memory placement: { X, 1, 2 } - // circular buffer: { 1, 2 } - BOOST_CHECK(*it1 == 1); - BOOST_CHECK(*it2 == 2); - BOOST_CHECK(cb[0] == 1); - BOOST_CHECK(cb[1] == 2); -} - -void validity_pop_front_test() { - - // memory placement: { 3, 1, 2 } - // circular buffer: { 1, 2, 3 } - circular_buffer cb(3); - cb.push_back(0); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - // it1 -> 2, it2 -> 3 - circular_buffer::iterator it1 = cb.begin() + 1; - circular_buffer::iterator it2 = cb.begin() + 2; - - cb.pop_front(); - - // memory placement: { 3, X, 2 } - // circular buffer: { 2, 3 } - BOOST_CHECK(*it1 == 2); - BOOST_CHECK(*it2 == 3); - BOOST_CHECK(cb[0] == 2); - BOOST_CHECK(cb[1] == 3); -} - -// test main -test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) { - - test_suite* tests = BOOST_TEST_SUITE("Unit tests for the iterator of the circular_buffer."); - - tests->add(BOOST_TEST_CASE(&validity_example_test)); - tests->add(BOOST_TEST_CASE(&validity_insert_test)); - tests->add(BOOST_TEST_CASE(&validity_insert_n_test)); - tests->add(BOOST_TEST_CASE(&validity_insert_range_test)); - tests->add(BOOST_TEST_CASE(&validity_rinsert_test)); - tests->add(BOOST_TEST_CASE(&validity_rinsert_n_test)); - tests->add(BOOST_TEST_CASE(&validity_rinsert_range_test)); - tests->add(BOOST_TEST_CASE(&validity_erase_test)); - tests->add(BOOST_TEST_CASE(&validity_erase_range_test)); - tests->add(BOOST_TEST_CASE(&validity_rerase_test)); - tests->add(BOOST_TEST_CASE(&validity_rerase_range_test)); - tests->add(BOOST_TEST_CASE(&validity_linearize_test)); - tests->add(BOOST_TEST_CASE(&validity_swap_test)); - tests->add(BOOST_TEST_CASE(&validity_push_back_test)); - tests->add(BOOST_TEST_CASE(&validity_push_front_test)); - tests->add(BOOST_TEST_CASE(&validity_pop_back_test)); - tests->add(BOOST_TEST_CASE(&validity_pop_front_test)); - - return tests; -} diff --git a/test/space_optimized_test.cpp b/test/space_optimized_test.cpp deleted file mode 100644 index b0c7884..0000000 --- a/test/space_optimized_test.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// Test of the space optimized adaptor of the circular buffer. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include "test.hpp" - -#define CB_CONTAINER circular_buffer_space_optimized - -#include "common.ipp" - -typedef circular_buffer_space_optimized cb_space_optimized; -typedef cb_space_optimized::capacity_type capacity_ctrl; - -// min_capacity test (it is useful to use a debug tool) -void min_capacity_test() { - - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - v.push_back(4); - v.push_back(5); - - cb_space_optimized cb1(capacity_ctrl(10, 10)); - cb_space_optimized cb2(capacity_ctrl(10, 5), 1); - cb_space_optimized cb3(capacity_ctrl(20, 10), v.begin(), v.end()); - - BOOST_CHECK(cb1.size() == 0); - BOOST_CHECK(cb1.capacity().capacity() == 10); - BOOST_CHECK(cb1.capacity().min_capacity() == 10); - BOOST_CHECK(cb2[0] == 1); - BOOST_CHECK(cb2.size() == 10); - BOOST_CHECK(cb2.capacity() == 10); - BOOST_CHECK(cb2.capacity().min_capacity() == 5); - BOOST_CHECK(cb3[0] == 1); - BOOST_CHECK(cb3.size() == 5); - BOOST_CHECK(cb3.capacity() == 20); - BOOST_CHECK(cb3.capacity().min_capacity() == 10); - BOOST_CHECK(cb1.capacity().min_capacity() <= cb1.internal_capacity()); - BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity()); - BOOST_CHECK(cb3.capacity().min_capacity() <= cb3.internal_capacity()); - - cb2.erase(cb2.begin() + 2, cb2.end()); - - BOOST_CHECK(cb2.size() == 2); - BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity()); - - cb2.clear(); - cb3.clear(); - - BOOST_CHECK(cb2.empty()); - BOOST_CHECK(cb3.empty()); - BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity()); - BOOST_CHECK(cb3.capacity().min_capacity() <= cb3.internal_capacity()); -} - -void capacity_control_test() { - - circular_buffer_space_optimized::capacity_type c1 = 10; - circular_buffer_space_optimized::capacity_type c2 = - circular_buffer_space_optimized::capacity_type(20, 5); - circular_buffer_space_optimized::capacity_type c3 = c2; - - BOOST_CHECK(c1.capacity() == 10); - BOOST_CHECK(c1.min_capacity() == 0); - BOOST_CHECK(c2.capacity() == 20); - BOOST_CHECK(c2.min_capacity() == 5); - BOOST_CHECK(c3.capacity() == 20); - BOOST_CHECK(c3.min_capacity() == 5); - - c1 = c2; - - BOOST_CHECK(c1.capacity() == 20); - BOOST_CHECK(c1.min_capacity() == 5); -} - -void some_constructors_test() { - - cb_space_optimized cb1; - BOOST_CHECK(cb1.capacity() == cb1.max_size()); - BOOST_CHECK(cb1.capacity().min_capacity() == 0); - BOOST_CHECK(cb1.internal_capacity() == 0); - BOOST_CHECK(cb1.size() == 0); - - cb1.push_back(1); - cb1.push_back(2); - cb1.push_back(3); - - BOOST_CHECK(cb1.size() == 3); - BOOST_CHECK(cb1.capacity() == cb1.max_size()); - - cb_space_optimized cb2(cb1.begin(), cb1.end()); - - BOOST_CHECK(cb2.capacity() == 3); - BOOST_CHECK(cb2.capacity().min_capacity() == 0); - BOOST_CHECK(cb2.size() == 3); -} - -void shrink_to_fit_test() { - - cb_space_optimized cb(1000); - cb.push_back(1); - cb.push_back(2); - cb.push_back(3); - - BOOST_CHECK(cb.size() == 3); - BOOST_CHECK(cb.capacity() == 1000); - - size_t internal_capacity = cb.internal_capacity(); - cb_space_optimized(cb).swap(cb); - - BOOST_CHECK(cb.size() == 3); - BOOST_CHECK(cb.capacity() == 1000); - BOOST_CHECK(internal_capacity >= cb.internal_capacity()); -} - -void iterator_invalidation_test() { - -#if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG) - - cb_space_optimized cb1(10, 1); - cb1.push_back(2); - cb1.push_back(3); - cb1.push_back(4); - cb_space_optimized::iterator it1 = cb1.end(); - cb_space_optimized::const_iterator it2 = cb1.begin(); - cb_space_optimized::iterator it3 = cb1.begin() + 6; - - cb1.set_capacity(10); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(!it3.is_valid(&cb1)); - - it1 = cb1.end(); - it2 = cb1.begin(); - it3 = cb1.begin() + 6; - cb1.rset_capacity(10); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(!it3.is_valid(&cb1)); - - it1 = cb1.end(); - it2 = cb1.begin(); - it3 = cb1.begin() + 6; - cb1.resize(10); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(!it3.is_valid(&cb1)); - - it1 = cb1.end(); - it2 = cb1.begin(); - it3 = cb1.begin() + 6; - cb1.rresize(10); - BOOST_CHECK(it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(!it3.is_valid(&cb1)); - - { - cb_space_optimized cb2(10, 1); - cb2.push_back(2); - cb2.push_back(3); - cb2.push_back(4); - it1 = cb2.end(); - it2 = cb2.begin(); - it3 = cb2.begin() + 6; - } - BOOST_CHECK(!it1.is_valid(&cb1)); - BOOST_CHECK(!it2.is_valid(&cb1)); - BOOST_CHECK(!it3.is_valid(&cb1)); - -#endif // #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG) -} - -// test main -test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) { - - test_suite* tests = BOOST_TEST_SUITE("Unit tests for the circular_buffer_space_optimized."); - add_common_tests(tests); - - tests->add(BOOST_TEST_CASE(&min_capacity_test)); - tests->add(BOOST_TEST_CASE(&capacity_control_test)); - tests->add(BOOST_TEST_CASE(&some_constructors_test)); - tests->add(BOOST_TEST_CASE(&shrink_to_fit_test)); - tests->add(BOOST_TEST_CASE(&iterator_invalidation_test)); - - return tests; -} diff --git a/test/test.hpp b/test/test.hpp deleted file mode 100644 index dc81c9e..0000000 --- a/test/test.hpp +++ /dev/null @@ -1,146 +0,0 @@ -// Header file for the test of the circular buffer library. - -// Copyright (c) 2003-2007 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_CIRCULAR_BUFFER_TEST_HPP) -#define BOOST_CIRCULAR_BUFFER_TEST_HPP - -#if defined(_MSC_VER) && _MSC_VER >= 1200 - #pragma once -#endif - -#define BOOST_CB_TEST - -#include -#include -#include -#include -#include -#include -#if !defined(BOOST_NO_EXCEPTIONS) - #include -#endif - -// Integer (substitute for int) - more appropriate for testing -class MyInteger { -private: - int* m_pValue; - static int ms_exception_trigger; - void check_exception() { - if (ms_exception_trigger > 0) { - if (--ms_exception_trigger == 0) { - delete m_pValue; - m_pValue = 0; -#if !defined(BOOST_NO_EXCEPTIONS) - throw std::exception(); -#endif - } - } - } -public: - MyInteger() : m_pValue(new int(0)) { check_exception(); } - MyInteger(int i) : m_pValue(new int(i)) { check_exception(); } - MyInteger(const MyInteger& src) : m_pValue(new int(src)) { check_exception(); } - ~MyInteger() { delete m_pValue; } - MyInteger& operator = (const MyInteger& src) { - if (this == &src) - return *this; - check_exception(); - delete m_pValue; - m_pValue = new int(src); - return *this; - } - operator int () const { return *m_pValue; } - static void set_exception_trigger(int n) { ms_exception_trigger = n; } -}; - -// default constructible class -class MyDefaultConstructible -{ -public: - MyDefaultConstructible() : m_n(1) {} - MyDefaultConstructible(int n) : m_n(n) {} - int m_n; -}; - -// class counting instances of self -class InstanceCounter { -public: - InstanceCounter() { increment(); } - InstanceCounter(const InstanceCounter& y) { y.increment(); } - ~InstanceCounter() { decrement(); } - static int count() { return ms_count; } -private: - void increment() const { ++ms_count; } - void decrement() const { --ms_count; } - static int ms_count; -}; - -// dummy class suitable for iterator referencing test -class Dummy { -public: - enum DummyEnum { - eVar, - eFnc, - eConst, - eVirtual - }; - Dummy() : m_n(eVar) {} - DummyEnum fnc() { return eFnc; } - DummyEnum const_fnc() const { return eConst; } - virtual DummyEnum virtual_fnc() { return eVirtual; } - DummyEnum m_n; -}; - -// simulator of an input iterator -struct MyInputIterator -: boost::iterator { - typedef std::vector::iterator vector_iterator; - typedef int value_type; - typedef int* pointer; - typedef int& reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - explicit MyInputIterator(const vector_iterator& it) : m_it(it) {} - MyInputIterator& operator = (const MyInputIterator& it) { - if (this == &it) - return *this; - m_it = it.m_it; - return *this; - } - reference operator * () const { return *m_it; } - pointer operator -> () const { return &(operator*()); } - MyInputIterator& operator ++ () { - ++m_it; - return *this; - } - MyInputIterator operator ++ (int) { - MyInputIterator tmp = *this; - ++*this; - return tmp; - } - bool operator == (const MyInputIterator& it) const { return m_it == it.m_it; } - bool operator != (const MyInputIterator& it) const { return m_it != it.m_it; } -private: - vector_iterator m_it; -}; - -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) - -inline std::input_iterator_tag iterator_category(const MyInputIterator&) { - return std::input_iterator_tag(); -} -inline int* value_type(const MyInputIterator&) { return 0; } -inline ptrdiff_t* distance_type(const MyInputIterator&) { return 0; } - -#endif // #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) - -using boost::unit_test::test_suite; -using namespace boost; -using namespace std; - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_TEST_HPP)