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<T, ALLOC></code> implements a unbounded storage array using an allocator. 18The unbounded array is similar to a <code>std::vector</code> in that in can grow in size beyond any fixed bound. 19However <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 <boost/numeric/ublas/storage.hpp> 25 26int main () { 27 using namespace boost::numeric::ublas; 28 unbounded_array<double> a (3); 29 for (unsigned i = 0; i < a.size (); ++ i) { 30 a [i] = i; 31 std::cout << a [i] << std::endl; 32 } 33} 34</pre> 35<h4>Definition</h4> 36<p>Defined in the header storage.hpp.</p> 37<h4>Template parameters</h4> 38<table border="1" summary="parameters"> 39<tbody> 40<tr> 41<th>Parameter</th> 42<th>Description</th> 43<th>Default</th> 44</tr> 45<tr> 46<td><code>T</code></td> 47<td>The type of object stored in the array.</td> 48<td></td> 49</tr> 50<tr> 51<td><code>ALLOC</code></td> 52<td>An STL Allocator</td> 53<td>std::allocator</td> 54</tr> 55</tbody> 56</table> 57<h4>Model of</h4> 58<p><a href="storage_concept.html">Storage</a></p> 59<h4>Type requirements</h4> 60<p>None, except for those imposed by the requirements of Storage.</p> 61<h4>Public base classes</h4> 62<p>None.</p> 63<h4>Members</h4> 64<ul> 65<li>The description does not describe what the member actually does, this can be looked up 66in the corresponding concept documentation, but instead contains a remark on the implementation of the 67member inside this model of the concept.</li> 68<li>Typography: 69<ul> 70<li>Members that are not part of the implemented concepts are <font color="blue">in blue</font>.</li> 71</ul> 72</li> 73</ul> 74<table border="1" summary="members"> 75<tbody> 76<tr> 77<th>Member</th> 78<th>Where defined</th> 79<th>Description</th> 80</tr> 81<tr><td><code>value_type</code></td><td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td><td></tr> 82<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> 83<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> 84<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&</code></td></tr> 85<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&</code></td></tr> 86<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> 87<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> 88<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> 89<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> 90<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<iterator></code></td></tr> 91<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<const_iterator></code></td></tr> 92<tr><td><font color="blue">allocator_type</font></td><td></td><td>Defined as ALLOC</td></tr> 93<tr> 94<td><code><em>explicit</em> unbounded_array (<em>ALLOC &a = ALLOC()</em>)</code></td> 95<td><a href="storage_concept.html">Storage</a></td> 96<td>Creates an <code>unbounded_array</code> that holds zero elements, using a specified allocator.</td> 97</tr> 98<tr> 99<td><code><em>explicit</em> unbounded_array (size_type size<em>, ALLOC &a = ALLOC()</em>)</code></td> 100<td><a href="storage_concept.html">Storage</a></td> 101<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> 102</tr> 103<tr> 104<td><code>unbounded_array (size_type size, const T& init<em>, ALLOC& a = ALLOC()</em>)</code></td> 105<td><a href="storage_concept.html">Storage</a></td> 106<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> 107</tr> 108<tr> 109<td><code>unbounded_array (const unbounded_array &a)</code></td> 110<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 111<td>The copy constructor.</td> 112</tr> 113<tr> 114<td><code>~unbounded_array ()</code></td> 115<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 116<td>Deallocates the <code>unbounded_array</code> itself.</td> 117</tr> 118<tr> 119<td><code>void resize (size_type n)</code></td> 120<td><a href="storage_concept.html">Storage</a></td> 121<td>Reallocates an <code>unbounded_array</code> to hold <code>n</code> elements. Values are uninitialised.</td> 122</tr> 123<tr> 124<td><code>void resize(size_type n, const T& t)</code></td> 125<td><a href="storage_concept.html">Storage</a></td> 126<td>Reallocates an <code>unbounded_array</code> to hold <code>n</code> elements. Values are copies of <code>t</code> 127</tr> 128<tr> 129<td><code>size_type size () const</code></td> 130<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 131<td>Returns the size of the <code>unbounded_array</code>.</td> 132</tr> 133<tr> 134<td><code>const_reference operator [] (size_type i) const</code></td> 135<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 136<td>Returns a <code>const</code> reference of the <code>i</code> -th element.</td> 137</tr> 138<tr> 139<td><code>reference operator [] (size_type i)</code></td> 140<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 141<td>Returns a reference of the <code>i</code>-th element.</td> 142</tr> 143<tr> 144<td><code>unbounded_array &operator = (const unbounded_array &a)</code></td> 145<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 146<td>The assignment operator.</td> 147</tr> 148<tr> 149<td><font color="blue"><code>unbounded_array &assign_temporary (unbounded_array &a)</code></font></td> 150<td></td> 151<td>Assigns a temporary. May change the array <code>a</code>.</td> 152</tr> 153<tr> 154<td><code>void swap (unbounded_array &a)</code></td> 155<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 156<td>Swaps the contents of the arrays.</td> 157</tr> 158<tr> 159<td><code>const_iterator begin () const</code></td> 160<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 161<td>Returns a <code>const_iterator</code> pointing to the beginning 162of the <code>unbounded_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 168the <code>unbounded_array</code>.</td> 169</tr> 170<tr> 171<td><code>iterator begin ()</code></td> 172<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 173<td>Returns a <code>iterator</code> pointing to the beginning of 174the <code>unbounded_array</code>.</td> 175</tr> 176<tr> 177<td><code>iterator end ()</code></td> 178<td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> 179<td>Returns a <code>iterator</code> pointing to the end of the 180<code>unbounded_array</code>.</td> 181</tr> 182<tr> 183<td><code>const_reverse_iterator rbegin () const</code></td> 184<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> 185<td>Returns a <code>const_reverse_iterator</code> pointing to the beginning of the reversed <code>unbounded_array</code>.</td> 186</tr> 187<tr> 188<td><code>const_reverse_iterator rend () const</code></td> 189<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> 190<td>Returns a <code>const_reverse_iterator</code> pointing to the end of the reversed <code>unbounded_array</code>.</td> 191</tr> 192<tr> 193<td><code>reverse_iterator rbegin ()</code></td> 194<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> 195<td>Returns a <code>reverse_iterator</code> pointing to the beginning of the reversed <code>unbounded_array</code>.</td> 196</tr> 197<tr> 198<td><code>reverse_iterator rend ()</code></td> 199<td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> 200<td>Returns a <code>reverse_iterator</code> pointing to the end of the reversed <code>unbounded_array</code>.</td> 201</tr> 202</tbody> 203</table> 204<hr /> 205<p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> 206 Use, modification and distribution are subject to the 207 Boost Software License, Version 1.0. 208 (See accompanying file LICENSE_1_0.txt 209 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> 210 http://www.boost.org/LICENSE_1_0.txt 211 </a>). 212</p> 213<script type="text/javascript"> 214(function($) { 215 $('#toc').toc(); 216})(jQuery); 217</script> 218</body> 219</html> 220