bounded_array.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  6. <link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
  7. <link rel="stylesheet" href="ublas.css" type="text/css" />
  8. <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
  9. <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
  10. <title>Bounded Array;</title>
  11. </head>
  12. <body>
  13. <h1><img src="../../../../boost.png" align="middle" />Bounded Array Storage</h1>
  14. <div class="toc" id="toc"></div>
  15. <h2><a name="bounded_array"></a>Bounded Array</h2>
  16. <h4>Description</h4>
  17. <p>The templated class <code>bounded_array&lt;T, N, ALLOC&gt;</code> implements a bounded storage array. The bounded array is similar to a C++ array type in that its maximum size is bounded by N and is allocated on the stack instead of the heap. Similarly a <code>bounded_array</code> requires no secondary storage and ALLOC is only used to specify <code>size_type</code> and <code>difference_type</code>.
  18. </p>
  19. <p>When resized <code>bounded_array</code> never reallocated the storage. It is therefore always efficient to resize a <code>bounded_array</code> but the size bound N must not be exceeded.</p>
  20. <h4>Example</h4>
  21. <pre>
  22. #include &lt;boost/numeric/ublas/storage.hpp&gt;
  23. int main () {
  24. using namespace boost::numeric::ublas;
  25. bounded_array&lt;double, 3&gt; a (3);
  26. for (unsigned i = 0; i &lt; a.size (); ++ i) {
  27. a [i] = i;
  28. std::cout &lt;&lt; a [i] &lt;&lt; std::endl;
  29. }
  30. }
  31. </pre>
  32. <h4>Definition</h4>
  33. <p>Defined in the header storage.hpp.</p>
  34. <h4>Template parameters</h4>
  35. <table border="1" summary="parameters">
  36. <tbody>
  37. <tr>
  38. <th>Parameter</th>
  39. <th>Description</th>
  40. <th>Default</th>
  41. </tr>
  42. <tr>
  43. <td><code>T</code></td>
  44. <td>The type of object stored in the array.</td>
  45. <td></td>
  46. </tr>
  47. <tr>
  48. <td><code>N</code></td>
  49. <td>The allocation size of the array.</td>
  50. <td></td>
  51. </tr>
  52. <tr>
  53. <td><code>ALLOC</code></td>
  54. <td>An STL Allocator</td>
  55. <td>std::allocator</td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. <h4>Model of</h4>
  60. <p><a href="storage_concept.html">Storage</a></p>
  61. <h4>Type requirements</h4>
  62. <p>None, except for those imposed by the requirements of Storage.</p>
  63. <h4>Public base classes</h4>
  64. <p>None.</p>
  65. <h4>Members</h4>
  66. <ul>
  67. <li>The description does not describe what the member actually does, this can be looked up
  68. in the corresponding concept documentation, but instead contains a remark on the implementation of the
  69. member inside this model of the concept.</li>
  70. <li>Typography:
  71. <ul>
  72. <li>Members that are not part of the implemented concepts are <font color="blue">in blue</font>.</li>
  73. </ul>
  74. </li>
  75. </ul>
  76. <table border="1" summary="members">
  77. <tbody>
  78. <tr>
  79. <th>Member</th>
  80. <th>Where defined</th>
  81. <th>Description</th>
  82. </tr>
  83. <tr><td><code>value_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td></tr>
  84. <tr><td><code>pointer</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>value_type*</code></td></tr>
  85. <tr><td><code>const_pointer</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const value_type*</code></td></tr>
  86. <tr><td><code>reference</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>value_type&amp;</code></td></tr>
  87. <tr><td><code>const_reference</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const value_type&amp;</code></td></tr>
  88. <tr><td><code>size_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>Alloc::size_type</code></td></tr>
  89. <tr><td><code>difference_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>Alloc::difference_type</code></td></tr>
  90. <tr><td><code>iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>pointer</code></td></tr>
  91. <tr><td><code>const_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>const_pointer</code></td></tr>
  92. <tr><td><code>revere_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>std::reverse_iterator&lt;iterator&gt;</code></td></tr>
  93. <tr><td><code>const_revere_iterator</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td>Defined as <code>std::reverse_iterator&lt;const_iterator&gt;</code></td></tr>
  94. <tr>
  95. <td><code>bounded_array ()</code></td>
  96. <td><a href="storage_concept.html">Storage</a></td>
  97. <td>Creates an <code>unbounded_array</code> that holds <strong>zero</strong> elements.</td>
  98. </tr>
  99. <tr>
  100. <td><code>bounded_array (size_type size)</code></td>
  101. <td><a href="storage_concept.html">Storage</a></td>
  102. <td>Creates a uninitialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are default constructed.</td>
  103. </tr>
  104. <tr>
  105. <td><code>bounded_array (size_type size, const T&amp; init)</code></td>
  106. <td><a href="storage_concept.html">Storage</a></td>
  107. <td>Creates an initialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are constructed from the <code>init</code> value.</td>
  108. </tr>
  109. <tr>
  110. <td><code>bounded_array (const bounded_array &amp;c)</code></td>
  111. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  112. <td>The copy constructor.</td>
  113. </tr>
  114. <tr>
  115. <td><code>~bounded_array ()</code></td>
  116. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  117. <td>Deallocates the <code>bounded_array</code> itself.</td>
  118. </tr>
  119. <tr>
  120. <td><code>void resize (size_type size)</code></td>
  121. <td><a href="storage_concept.html">Storage</a>
  122. <td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td>
  123. </tr>
  124. <tr>
  125. <td><code>void resize (size_type size, const T&amp; t)</code></td>
  126. <td><a href="storage_concept.html">Storage</a>
  127. <td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td>
  128. </tr>
  129. <tr>
  130. <td><code>size_type size () const</code></td>
  131. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  132. <td>Returns the size of the <code>bounded_array</code>.</td>
  133. </tr>
  134. <tr>
  135. <td><code>const_reference operator [] (size_type i) const</code></td>
  136. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  137. <td>Returns a <code>const</code> reference of the <code>i</code> -th element.</td>
  138. </tr>
  139. <tr>
  140. <td><code>reference operator [] (size_type i)</code></td>
  141. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  142. <td>Returns a reference of the <code>i</code>-th element.</td>
  143. </tr>
  144. <tr>
  145. <td><code>bounded_array &amp;operator = (const bounded_array &amp;a)</code></td>
  146. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  147. <td>The assignment operator.</td>
  148. </tr>
  149. <tr>
  150. <td><font color="blue"><code>bounded_array &amp;assign_temporary (bounded_array &amp;a)</code></font></td>
  151. <td></td>
  152. <td>Assigns a temporary. May change the array <code>a</code>.</td>
  153. </tr>
  154. <tr>
  155. <td><code>void swap (bounded_array &amp;a)</code></td>
  156. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  157. <td>Swaps the contents of the arrays.</td>
  158. </tr>
  159. <tr>
  160. <td><code>const_iterator begin () const</code></td>
  161. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  162. <td>Returns a <code>const_iterator</code> pointing to the beginning of the <code>bounded_array</code>.</td>
  163. </tr>
  164. <tr>
  165. <td><code>const_iterator end () const</code></td>
  166. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  167. <td>Returns a <code>const_iterator</code> pointing to the end of the <code>bounded_array</code>.</td>
  168. </tr>
  169. <tr>
  170. <td><code>iterator begin ()</code></td>
  171. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  172. <td>Returns a <code>iterator</code> pointing to the beginning of the <code>bounded_array</code>.</td>
  173. </tr>
  174. <tr>
  175. <td><code>iterator end ()</code></td>
  176. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  177. <td>Returns a <code>iterator</code> pointing to the end of the <code>bounded_array</code>.</td>
  178. </tr>
  179. <tr>
  180. <td><code>const_reverse_iterator rbegin () const</code></td>
  181. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  182. <td>Returns a <code>const_reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td>
  183. </tr>
  184. <tr>
  185. <td><code>const_reverse_iterator rend () const</code></td>
  186. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  187. <td>Returns a <code>const_reverse_iterator</code> pointing to the end of the reversed <code>bounded_array</code>.</td>
  188. </tr>
  189. <tr>
  190. <td><code>reverse_iterator rbegin ()</code></td>
  191. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  192. <td>Returns a <code>reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td>
  193. </tr>
  194. <tr>
  195. <td><code>reverse_iterator rend ()</code></td>
  196. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  197. <td>Returns a <code>reverse_iterator</code> pointing to the end of the reversed <code>bounded_array</code>.</td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. <hr />
  202. <p>
  203. Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
  204. Joerg Walter, Gunter Winkler<br />
  205. Use, modification and distribution are subject to the
  206. Boost Software License, Version 1.0.
  207. (See accompanying file LICENSE_1_0.txt
  208. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  209. http://www.boost.org/LICENSE_1_0.txt
  210. </a>).
  211. </p>
  212. <script type="text/javascript">
  213. (function($) {
  214. $('#toc').toc();
  215. })(jQuery);
  216. </script>
  217. </body>
  218. </html>