| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>Rationale</title> |
| <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> |
| <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> |
| <link rel="up" href="../circular_buffer.html" title="Chapter 7. Boost.Circular Buffer"> |
| <link rel="prev" href="example.html" title="Circular_buffer example"> |
| <link rel="next" href="implementation.html" title="Implementation"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> |
| <td align="center"><a href="../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <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> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| <a name="circular_buffer.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a> |
| </h2></div></div></div> |
| <p> |
| 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> |
| was to create a container which would <span class="bold"><strong>work seamlessly |
| with STL</strong></span>. |
| </p> |
| <p> |
| 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> |
| was guided by the following principles: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| Maximum <span class="emphasis"><em>efficiency</em></span> for envisaged applications. |
| </li> |
| <li class="listitem"> |
| Suitable for <span class="emphasis"><em>general purpose use</em></span>. |
| </li> |
| <li class="listitem"> |
| The behaviour of the buffer as <span class="emphasis"><em>intuitive</em></span> as possible. |
| </li> |
| <li class="listitem"> |
| Suitable for <span class="emphasis"><em>specialization</em></span> by means of adaptors. |
| (The <code class="computeroutput"><a class="link" href="../boost/circular_buffe_idp38268896.html" title="Class template circular_buffer_space_optimized">circular_buffer_space_optimized</a></code> |
| is such an example of the adaptor.) |
| </li> |
| <li class="listitem"> |
| Easy to <span class="emphasis"><em>debug</em></span>. (See Debug Support for details.) |
| </li> |
| </ul></div> |
| <p> |
| 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> |
| and <code class="computeroutput"><a class="link" href="../boost/circular_buffe_idp38268896.html" title="Class template circular_buffer_space_optimized">circular_buffer_space_optimized</a></code> |
| store their elements in a <span class="bold"><strong>contiguous region of memory</strong></span>, |
| which then enables: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| Use of fixed memory and no implicit or unexpected memory allocation. |
| </li> |
| <li class="listitem"> |
| Fast constant-time insertion and removal of elements from the front and |
| back. |
| </li> |
| <li class="listitem"> |
| Fast constant-time random access of elements. |
| </li> |
| <li class="listitem"> |
| Suitability for real-time and performance critical applications. |
| </li> |
| </ul></div> |
| <p> |
| Possible applications of the circular buffer include: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| Storage of the <span class="emphasis"><em>most recently received samples</em></span>, overwriting |
| the oldest as new samples arrive. |
| </li> |
| <li class="listitem"> |
| As an underlying container for a <span class="emphasis"><em>bounded buffer</em></span> (see |
| 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>). |
| </li> |
| <li class="listitem"> |
| A kind of <span class="emphasis"><em>cache</em></span> storing a specified number of last |
| inserted elements. |
| </li> |
| <li class="listitem"> |
| Efficient fixed capacity <span class="emphasis"><em>FIFO (First In, First Out)</em></span>, |
| </li> |
| <li class="listitem"> |
| Efficient fixed capacity <span class="emphasis"><em>LIFO (Last In, First Out)</em></span> |
| queue which removes the oldest (inserted as first) elements when full. |
| </li> |
| </ul></div> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"></td> |
| <td align="right"><div class="copyright-footer">Copyright © 2003-2013 Jan Gaspar<p> |
| Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 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>) |
| </p> |
| </div></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <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> |
| </div> |
| </body> |
| </html> |