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">
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>
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>
20 <p>The templated class <code>map_std<I, T, ALLOC></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>
27 #include <boost/numeric/ublas/storage_sparse.hpp>
30 using namespace boost::numeric::ublas;
31 map_std<int, double> a (3);
32 for (unsigned i = 0; i < a.size (); ++ i) {
34 std::cout << a [i] << std::endl;
39 <p>Defined in the header storage_sparse.hpp.</p>
40 <h4>Template parameters</h4>
41 <table border="1" summary="parameters">
49 <td><code>I</code></td>
50 <td>The type of index stored in the array.</td>
54 <td><code>T</code></td>
55 <td>The type of object stored in the array.</td>
59 <td><code>ALLOC</code></td>
60 <td>An STL Allocator</td>
61 <td>std::allocator</td>
66 <p>Reversible Container.</p>
67 <h4>Type requirements</h4>
68 <p>None, except for those imposed by the requirements of Reversible
70 <h4>Public base classes</h4>
72 <h2><a name="map_array"></a>Map Array</h2>
74 <p>The templated class <code>map_array<I, T, ALLOC></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.
81 #include <boost/numeric/ublas/storage_sparse.hpp>
84 using namespace boost::numeric::ublas;
85 map_array<int, double> a (3);
86 for (unsigned i = 0; i < a.size (); ++ i) {
88 std::cout << a [i] << std::endl;
93 <p>Defined in the header storage_sparse.hpp.</p>
94 <h4>Template parameters</h4>
95 <table border="1" summary="parameters">
103 <td><code>I</code></td>
104 <td>The type of index stored in the array.</td>
108 <td><code>T</code></td>
109 <td>The type of object stored in the array.</td>
113 <td><code>ALLOC</code></td>
114 <td>An STL Allocator</td>
115 <td>std::allocator</td>
120 <p>Reversible Container.</p>
121 <h4>Type requirements</h4>
122 <p>None, except for those imposed by the requirements of Reversible
124 <h4>Public base classes</h4>
127 <table border="1" summary="members">
134 <td><code>map_array (ALLOC &a = ALLOC())</code></td>
135 <td>Allocates a <code>map_array</code> that holds at most zero
139 <td><code>map_array (const map_array &c)</code></td>
140 <td>The copy constructor.</td>
143 <td><code>~map_array ()</code></td>
144 <td>Deallocates the <code>map_array</code> itself.</td>
147 <td><code>void reserve (size_type capacity)</code></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>
152 <td><code>size_type size () const</code></td>
153 <td>Returns the size of the <code>map_array</code>.</td>
156 <td><code>size_type size () const</code></td>
157 <td>Returns the capacity of the <code>map_array</code>.</td>
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>
167 <td><code>map_array &operator = (const map_array
169 <td>The assignment operator.</td>
172 <td><code>map_array &assign_temporary (map_array
174 <td>Assigns a temporary. May change the array <code>a</code>.</td>
177 <td><code>void swap (map_array &a)</code></td>
178 <td>Swaps the contents of the arrays.</td>
181 <td><code>std::pair<iterator, bool> insert (const value_type
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
188 <td><code>iterator insert (iterator it, const value_type
190 <td>Inserts <code>p</code> into the array, using <code>it</code> as
191 a hint to where it will be inserted.</td>
194 <td><code>void erase (iterator it)</code></td>
195 <td>Erases the value at <code>it</code>.</td>
198 <td><code>void clear ()</code></td>
199 <td>Clears the array.</td>
202 <td><code>const_iterator find (index_type i) const</code></td>
203 <td>Finds an element whose index is <code>i</code>.</td>
206 <td><code>iterator find (index_type i)</code></td>
207 <td>Finds an element whose index is <code>i</code>.</td>
210 <td><code>const_iterator lower_bound (index_type i)
212 <td>Finds the first element whose index is not less than
213 <code>i</code> .</td>
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>
221 <td><code>const_iterator upper_bound (index_type i)
223 <td>Finds the first element whose index is greater than
224 <code>i</code> .</td>
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>
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>
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>
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>
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>
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>
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>
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>
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>
274 <p>Copyright (©) 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
282 <script type="text/javascript">