unbounded_array.html 10 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>Unbounded array</title>
  11. </head>
  12. <body>
  13. <h1><img src="../../../../boost.png" align="middle" />Unbounded Array Storage</h1>
  14. <div class="toc" id="toc"></div>
  15. <h2><a name="unbounded_array"></a>Unbounded Array</h2>
  16. <h4>Description</h4>
  17. <p>The templated class <code>unbounded_array&lt;T, ALLOC&gt;</code> implements a unbounded storage array using an allocator.
  18. The unbounded array is similar to a <code>std::vector</code> in that in can grow in size beyond any fixed bound.
  19. However <code>unbounded_array</code> is aimed at optimal performance. Therefore <code>unbounded_array</code> does not model a
  20. <code>Sequence</code> like <code>std::vector</code> does.
  21. <p>When resized <code>unbounded_array</code> will reallocate it's storage even if the new size requirement is smaller. It is therefore inefficient to resize a <code>unbounded_array</code></p>
  22. <h4>Example</h4>
  23. <pre>
  24. #include &lt;boost/numeric/ublas/storage.hpp&gt;
  25. int main () {
  26. using namespace boost::numeric::ublas;
  27. unbounded_array&lt;double&gt; a (3);
  28. for (unsigned i = 0; i &lt; a.size (); ++ i) {
  29. a [i] = i;
  30. std::cout &lt;&lt; a [i] &lt;&lt; std::endl;
  31. }
  32. }
  33. </pre>
  34. <h4>Definition</h4>
  35. <p>Defined in the header storage.hpp.</p>
  36. <h4>Template parameters</h4>
  37. <table border="1" summary="parameters">
  38. <tbody>
  39. <tr>
  40. <th>Parameter</th>
  41. <th>Description</th>
  42. <th>Default</th>
  43. </tr>
  44. <tr>
  45. <td><code>T</code></td>
  46. <td>The type of object stored in the array.</td>
  47. <td></td>
  48. </tr>
  49. <tr>
  50. <td><code>ALLOC</code></td>
  51. <td>An STL Allocator</td>
  52. <td>std::allocator</td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. <h4>Model of</h4>
  57. <p><a href="storage_concept.html">Storage</a></p>
  58. <h4>Type requirements</h4>
  59. <p>None, except for those imposed by the requirements of Storage.</p>
  60. <h4>Public base classes</h4>
  61. <p>None.</p>
  62. <h4>Members</h4>
  63. <ul>
  64. <li>The description does not describe what the member actually does, this can be looked up
  65. in the corresponding concept documentation, but instead contains a remark on the implementation of the
  66. member inside this model of the concept.</li>
  67. <li>Typography:
  68. <ul>
  69. <li>Members that are not part of the implemented concepts are <font color="blue">in blue</font>.</li>
  70. </ul>
  71. </li>
  72. </ul>
  73. <table border="1" summary="members">
  74. <tbody>
  75. <tr>
  76. <th>Member</th>
  77. <th>Where defined</th>
  78. <th>Description</th>
  79. </tr>
  80. <tr><td><code>value_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td></tr>
  81. <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>
  82. <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>
  83. <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>
  84. <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>
  85. <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>
  86. <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>
  87. <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>
  88. <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>
  89. <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>
  90. <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>
  91. <tr><td><font color="blue">allocator_type</font></td><td></td><td>Defined as ALLOC</td></tr>
  92. <tr>
  93. <td><code><em>explicit</em> unbounded_array (<em>ALLOC &amp;a = ALLOC()</em>)</code></td>
  94. <td><a href="storage_concept.html">Storage</a></td>
  95. <td>Creates an <code>unbounded_array</code> that holds zero elements, using a specified allocator.</td>
  96. </tr>
  97. <tr>
  98. <td><code><em>explicit</em> unbounded_array (size_type size<em>, ALLOC &amp;a = ALLOC()</em>)</code></td>
  99. <td><a href="storage_concept.html">Storage</a></td>
  100. <td>Creates a uninitialized <code>unbounded_array</code> that holds <code>size</code> elements, using a specified allocator. All the elements are default constructed.</td>
  101. </tr>
  102. <tr>
  103. <td><code>unbounded_array (size_type size, const T&amp; init<em>, ALLOC&amp; a = ALLOC()</em>)</code></td>
  104. <td><a href="storage_concept.html">Storage</a></td>
  105. <td>Creates an initialized <code>unbounded_array</code> that holds <code>size</code> elements, using a specified allocator. All the elements are constructed from the <code>init</code> value.</td>
  106. </tr>
  107. <tr>
  108. <td><code>unbounded_array (const unbounded_array &amp;a)</code></td>
  109. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  110. <td>The copy constructor.</td>
  111. </tr>
  112. <tr>
  113. <td><code>~unbounded_array ()</code></td>
  114. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  115. <td>Deallocates the <code>unbounded_array</code> itself.</td>
  116. </tr>
  117. <tr>
  118. <td><code>void resize (size_type n)</code></td>
  119. <td><a href="storage_concept.html">Storage</a></td>
  120. <td>Reallocates an <code>unbounded_array</code> to hold <code>n</code> elements. Values are uninitialised.</td>
  121. </tr>
  122. <tr>
  123. <td><code>void resize(size_type n, const T&amp; t)</code></td>
  124. <td><a href="storage_concept.html">Storage</a></td>
  125. <td>Reallocates an <code>unbounded_array</code> to hold <code>n</code> elements. Values are copies of <code>t</code>
  126. </tr>
  127. <tr>
  128. <td><code>size_type size () const</code></td>
  129. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  130. <td>Returns the size of the <code>unbounded_array</code>.</td>
  131. </tr>
  132. <tr>
  133. <td><code>const_reference operator [] (size_type i) const</code></td>
  134. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  135. <td>Returns a <code>const</code> reference of the <code>i</code> -th element.</td>
  136. </tr>
  137. <tr>
  138. <td><code>reference operator [] (size_type i)</code></td>
  139. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  140. <td>Returns a reference of the <code>i</code>-th element.</td>
  141. </tr>
  142. <tr>
  143. <td><code>unbounded_array &amp;operator = (const unbounded_array &amp;a)</code></td>
  144. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  145. <td>The assignment operator.</td>
  146. </tr>
  147. <tr>
  148. <td><font color="blue"><code>unbounded_array &amp;assign_temporary (unbounded_array &amp;a)</code></font></td>
  149. <td></td>
  150. <td>Assigns a temporary. May change the array <code>a</code>.</td>
  151. </tr>
  152. <tr>
  153. <td><code>void swap (unbounded_array &amp;a)</code></td>
  154. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  155. <td>Swaps the contents of the arrays.</td>
  156. </tr>
  157. <tr>
  158. <td><code>const_iterator begin () const</code></td>
  159. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  160. <td>Returns a <code>const_iterator</code> pointing to the beginning
  161. of the <code>unbounded_array</code>.</td>
  162. </tr>
  163. <tr>
  164. <td><code>const_iterator end () const</code></td>
  165. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  166. <td>Returns a <code>const_iterator</code> pointing to the end of
  167. the <code>unbounded_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
  173. the <code>unbounded_array</code>.</td>
  174. </tr>
  175. <tr>
  176. <td><code>iterator end ()</code></td>
  177. <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td>
  178. <td>Returns a <code>iterator</code> pointing to the end of the
  179. <code>unbounded_array</code>.</td>
  180. </tr>
  181. <tr>
  182. <td><code>const_reverse_iterator rbegin () const</code></td>
  183. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  184. <td>Returns a <code>const_reverse_iterator</code> pointing to the beginning of the reversed <code>unbounded_array</code>.</td>
  185. </tr>
  186. <tr>
  187. <td><code>const_reverse_iterator rend () const</code></td>
  188. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  189. <td>Returns a <code>const_reverse_iterator</code> pointing to the end of the reversed <code>unbounded_array</code>.</td>
  190. </tr>
  191. <tr>
  192. <td><code>reverse_iterator rbegin ()</code></td>
  193. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  194. <td>Returns a <code>reverse_iterator</code> pointing to the beginning of the reversed <code>unbounded_array</code>.</td>
  195. </tr>
  196. <tr>
  197. <td><code>reverse_iterator rend ()</code></td>
  198. <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td>
  199. <td>Returns a <code>reverse_iterator</code> pointing to the end of the reversed <code>unbounded_array</code>.</td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <hr />
  204. <p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<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>