summaryrefslogtreecommitdiff
path: root/doc/html/circular_buffer/rationale.html
blob: 6d03e47c04311fbff94dd965b87cc1459f7609aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../circular_buffer.html" title="Chapter&#160;8.&#160;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_idm45717958544272.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_idm45717958544272.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 &#169; 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>