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