storage_sparse.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 name="generator" content=
  6. "HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
  7. <meta http-equiv="Content-Type" content=
  8. "text/html; charset=us-ascii" />
  9. <link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
  10. <link rel="stylesheet" href="ublas.css" type="text/css" />
  11. <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
  12. <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
  13. <title>Sparse Storage</title>
  14. </head>
  15. <body>
  16. <h1><img src="../../../../boost.png" align="middle" />Sparse Storage</h1>
  17. <div class="toc" id="toc"></div>
  18. <h2><a name="map_std"></a>Default Standard Map</h2>
  19. <h4>Description</h4>
  20. <p>The templated class <code>map_std&lt;I, T, ALLOC&gt;</code> provides a
  21. wrapper for the standard library associative container
  22. <code>std::map</code>. The wrapper has one simple purpose. It
  23. allows the definition of a default template parameter (for the
  24. adapted array) when declaring the sparse container types.</p>
  25. <h4>Example</h4>
  26. <pre>
  27. #include &lt;boost/numeric/ublas/storage_sparse.hpp&gt;
  28. int main () {
  29. using namespace boost::numeric::ublas;
  30. map_std&lt;int, double&gt; a (3);
  31. for (unsigned i = 0; i &lt; a.size (); ++ i) {
  32. a [i] = i;
  33. std::cout &lt;&lt; a [i] &lt;&lt; std::endl;
  34. }
  35. }
  36. </pre>
  37. <h4>Definition</h4>
  38. <p>Defined in the header storage_sparse.hpp.</p>
  39. <h4>Template parameters</h4>
  40. <table border="1" summary="parameters">
  41. <tbody>
  42. <tr>
  43. <th>Parameter</th>
  44. <th>Description</th>
  45. <th>Default</th>
  46. </tr>
  47. <tr>
  48. <td><code>I</code></td>
  49. <td>The type of index stored in the array.</td>
  50. <td></td>
  51. </tr>
  52. <tr>
  53. <td><code>T</code></td>
  54. <td>The type of object stored in the array.</td>
  55. <td></td>
  56. </tr>
  57. <tr>
  58. <td><code>ALLOC</code></td>
  59. <td>An STL Allocator</td>
  60. <td>std::allocator</td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. <h4>Model of</h4>
  65. <p>Reversible Container.</p>
  66. <h4>Type requirements</h4>
  67. <p>None, except for those imposed by the requirements of Reversible
  68. Container.</p>
  69. <h4>Public base classes</h4>
  70. <p>std::map</p>
  71. <h2><a name="map_array"></a>Map Array</h2>
  72. <h4>Description</h4>
  73. <p>The templated class <code>map_array&lt;I, T, ALLOC&gt;</code> implements a <code>std::map</code> like associative container as a sorted array. It therefore some of the Associative Container interface without having the same semantics as an std::map.
  74. <p>At any time the <code>map_array</code> has a capacity up to which new element can be inserted.
  75. If <code>insert</code> would cause the size of the <code>map_array</code> to exceeds its capactity then it is <strong>reallocated</strong>. Iterators and reference are invalidated.
  76. The capacity can be directly control using the <code>reserve</code> member function.
  77. </p>
  78. <h4>Example</h4>
  79. <pre>
  80. #include &lt;boost/numeric/ublas/storage_sparse.hpp&gt;
  81. int main () {
  82. using namespace boost::numeric::ublas;
  83. map_array&lt;int, double&gt; a (3);
  84. for (unsigned i = 0; i &lt; a.size (); ++ i) {
  85. a [i] = i;
  86. std::cout &lt;&lt; a [i] &lt;&lt; std::endl;
  87. }
  88. }
  89. </pre>
  90. <h4>Definition</h4>
  91. <p>Defined in the header storage_sparse.hpp.</p>
  92. <h4>Template parameters</h4>
  93. <table border="1" summary="parameters">
  94. <tbody>
  95. <tr>
  96. <th>Parameter</th>
  97. <th>Description</th>
  98. <th>Default</th>
  99. </tr>
  100. <tr>
  101. <td><code>I</code></td>
  102. <td>The type of index stored in the array.</td>
  103. <td></td>
  104. </tr>
  105. <tr>
  106. <td><code>T</code></td>
  107. <td>The type of object stored in the array.</td>
  108. <td></td>
  109. </tr>
  110. <tr>
  111. <td><code>ALLOC</code></td>
  112. <td>An STL Allocator</td>
  113. <td>std::allocator</td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <h4>Model of</h4>
  118. <p>Reversible Container.</p>
  119. <h4>Type requirements</h4>
  120. <p>None, except for those imposed by the requirements of Reversible
  121. Container.</p>
  122. <h4>Public base classes</h4>
  123. <p>None.</p>
  124. <h4>Members</h4>
  125. <table border="1" summary="members">
  126. <tbody>
  127. <tr>
  128. <th>Member</th>
  129. <th>Description</th>
  130. </tr>
  131. <tr>
  132. <td><code>map_array (ALLOC &amp;a = ALLOC())</code></td>
  133. <td>Allocates a <code>map_array</code> that holds at most zero
  134. elements.</td>
  135. </tr>
  136. <tr>
  137. <td><code>map_array (const map_array &amp;c)</code></td>
  138. <td>The copy constructor.</td>
  139. </tr>
  140. <tr>
  141. <td><code>~map_array ()</code></td>
  142. <td>Deallocates the <code>map_array</code> itself.</td>
  143. </tr>
  144. <tr>
  145. <td><code>void reserve (size_type capacity)</code></td>
  146. <td>
  147. Changes the<code>map_array</code> capacity. It can hold at most<code>capacity</code> elements without reallocation. The capacity can be reduced such that <code>capacity >= size()</code>. The content of the<code>map_array</code> is preserved.</td>
  148. </tr>
  149. <tr>
  150. <td><code>size_type size () const</code></td>
  151. <td>Returns the size of the <code>map_array</code>.</td>
  152. </tr>
  153. <tr>
  154. <td><code>size_type size () const</code></td>
  155. <td>Returns the capacity of the <code>map_array</code>.</td>
  156. </tr>
  157. <tr>
  158. <td><code>data_reference operator [] (index_type i)</code></td>
  159. <td>Returns a reference of the element that is associated with a
  160. particular index. If the <code>map_array</code> does not already
  161. contain such an element, <code>operator[]</code> inserts the
  162. default <code>T ()</code>.</td>
  163. </tr>
  164. <tr>
  165. <td><code>map_array &amp;operator = (const map_array
  166. &amp;a)</code></td>
  167. <td>The assignment operator.</td>
  168. </tr>
  169. <tr>
  170. <td><code>map_array &amp;assign_temporary (map_array
  171. &amp;a)</code></td>
  172. <td>Assigns a temporary. May change the array <code>a</code>.</td>
  173. </tr>
  174. <tr>
  175. <td><code>void swap (map_array &amp;a)</code></td>
  176. <td>Swaps the contents of the arrays.</td>
  177. </tr>
  178. <tr>
  179. <td><code>std::pair<iterator, bool> insert (const value_type
  180. &amp;p)</code></td>
  181. <td>Inserts <code>p</code> into the array. The second part of the return value is <code>true</code>
  182. if <code>p</code> was inserted and <code>false</code> if was not inserted because it was aleady
  183. present.</td>
  184. </tr>
  185. <tr>
  186. <td><code>iterator insert (iterator it, const value_type
  187. &amp;p)</code></td>
  188. <td>Inserts <code>p</code> into the array, using <code>it</code> as
  189. a hint to where it will be inserted.</td>
  190. </tr>
  191. <tr>
  192. <td><code>void erase (iterator it)</code></td>
  193. <td>Erases the value at <code>it</code>.</td>
  194. </tr>
  195. <tr>
  196. <td><code>void clear ()</code></td>
  197. <td>Clears the array.</td>
  198. </tr>
  199. <tr>
  200. <td><code>const_iterator find (index_type i) const</code></td>
  201. <td>Finds an element whose index is <code>i</code>.</td>
  202. </tr>
  203. <tr>
  204. <td><code>iterator find (index_type i)</code></td>
  205. <td>Finds an element whose index is <code>i</code>.</td>
  206. </tr>
  207. <tr>
  208. <td><code>const_iterator lower_bound (index_type i)
  209. const</code></td>
  210. <td>Finds the first element whose index is not less than
  211. <code>i</code> .</td>
  212. </tr>
  213. <tr>
  214. <td><code>iterator lower_bound (index_type i)</code></td>
  215. <td>Finds the first element whose index is not less than
  216. <code>i</code> .</td>
  217. </tr>
  218. <tr>
  219. <td><code>const_iterator upper_bound (index_type i)
  220. const</code></td>
  221. <td>Finds the first element whose index is greater than
  222. <code>i</code> .</td>
  223. </tr>
  224. <tr>
  225. <td><code>iterator upper_bound (index_type i)</code></td>
  226. <td>Finds the first element whose index is greater than
  227. <code>i</code> .</td>
  228. </tr>
  229. <tr>
  230. <td><code>const_iterator begin () const</code></td>
  231. <td>Returns a <code>const_iterator</code> pointing to the beginning
  232. of the <code>map_array</code>.</td>
  233. </tr>
  234. <tr>
  235. <td><code>const_iterator end () const</code></td>
  236. <td>Returns a <code>const_iterator</code> pointing to the end of
  237. the <code>map_array</code>.</td>
  238. </tr>
  239. <tr>
  240. <td><code>iterator begin ()</code></td>
  241. <td>Returns a <code>iterator</code> pointing to the beginning of
  242. the <code>map_array</code>.</td>
  243. </tr>
  244. <tr>
  245. <td><code>iterator end ()</code></td>
  246. <td>Returns a <code>iterator</code> pointing to the end of the
  247. <code>map_array</code>.</td>
  248. </tr>
  249. <tr>
  250. <td><code>const_reverse_iterator rbegin () const</code></td>
  251. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  252. beginning of the reversed <code>map_array</code>.</td>
  253. </tr>
  254. <tr>
  255. <td><code>const_reverse_iterator rend () const</code></td>
  256. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  257. end of the reversed <code>map_array</code>.</td>
  258. </tr>
  259. <tr>
  260. <td><code>reverse_iterator rbegin ()</code></td>
  261. <td>Returns a <code>reverse_iterator</code> pointing to the
  262. beginning of the reversed <code>map_array</code>.</td>
  263. </tr>
  264. <tr>
  265. <td><code>reverse_iterator rend ()</code></td>
  266. <td>Returns a <code>reverse_iterator</code> pointing to the end of
  267. the reversed <code>map_array</code>.</td>
  268. </tr>
  269. </tbody>
  270. </table>
  271. <hr />
  272. <p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
  273. Use, modification and distribution are subject to the
  274. Boost Software License, Version 1.0.
  275. (See accompanying file LICENSE_1_0.txt
  276. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  277. http://www.boost.org/LICENSE_1_0.txt
  278. </a>).
  279. </p>
  280. <script type="text/javascript">
  281. (function($) {
  282. $('#toc').toc();
  283. })(jQuery);
  284. </script>
  285. </body>
  286. </html>