1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Rationale</title>
6 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../circular_buffer.html" title="Chapter 9. Boost.Circular Buffer">
10 <link rel="prev" href="example.html" title="Circular_buffer example">
11 <link rel="next" href="implementation.html" title="Implementation">
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
16 <td align="center"><a href="../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../more/index.htm">More</a></td>
23 <div class="spirit-nav">
24 <a accesskey="p" href="example.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../circular_buffer.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="circular_buffer.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a>
29 </h2></div></div></div>
31 The basic motivation behind the <code class="computeroutput"><a class="link" href="../boost/circular_buffer.html" title="Class template circular_buffer">circular_buffer</a></code>
32 was to create a container which would <span class="bold"><strong>work seamlessly
33 with STL</strong></span>.
36 Additionally, the design of the <code class="computeroutput"><a class="link" href="../boost/circular_buffer.html" title="Class template circular_buffer">circular_buffer</a></code>
37 was guided by the following principles:
39 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
41 Maximum <span class="emphasis"><em>efficiency</em></span> for envisaged applications.
44 Suitable for <span class="emphasis"><em>general purpose use</em></span>.
47 The behaviour of the buffer as <span class="emphasis"><em>intuitive</em></span> as possible.
50 Suitable for <span class="emphasis"><em>specialization</em></span> by means of adaptors.
51 (The <code class="computeroutput"><a class="link" href="../boost/circular_buffe_idp26541888.html" title="Class template circular_buffer_space_optimized">circular_buffer_space_optimized</a></code>
52 is such an example of the adaptor.)
55 Easy to <span class="emphasis"><em>debug</em></span>. (See Debug Support for details.)
59 In order to achieve maximum efficiency, the <code class="computeroutput"><a class="link" href="../boost/circular_buffer.html" title="Class template circular_buffer">circular_buffer</a></code>
60 and <code class="computeroutput"><a class="link" href="../boost/circular_buffe_idp26541888.html" title="Class template circular_buffer_space_optimized">circular_buffer_space_optimized</a></code>
61 store their elements in a <span class="bold"><strong>contiguous region of memory</strong></span>,
64 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
66 Use of fixed memory and no implicit or unexpected memory allocation.
69 Fast constant-time insertion and removal of elements from the front and
73 Fast constant-time random access of elements.
76 Suitability for real-time and performance critical applications.
80 Possible applications of the circular buffer include:
82 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
84 Storage of the <span class="emphasis"><em>most recently received samples</em></span>, overwriting
85 the oldest as new samples arrive.
88 As an underlying container for a <span class="emphasis"><em>bounded buffer</em></span> (see
89 the Bounded Buffer example, code at <a href="../../../libs/circular_buffer/example/circular_buffer_bound_example.cpp" target="_top">circular_buffer_bound_example.cpp</a>).
92 A kind of <span class="emphasis"><em>cache</em></span> storing a specified number of last
96 Efficient fixed capacity <span class="emphasis"><em>FIFO (First In, First Out)</em></span>,
99 Efficient fixed capacity <span class="emphasis"><em>LIFO (Last In, First Out)</em></span>
100 queue which removes the oldest (inserted as first) elements when full.
104 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
105 <td align="left"></td>
106 <td align="right"><div class="copyright-footer">Copyright © 2003-2013 Jan Gaspar<p>
107 Distributed under the Boost Software License, Version 1.0. (See accompanying
108 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
113 <div class="spirit-nav">
114 <a accesskey="p" href="example.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../circular_buffer.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>