| 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 href="ublas.css" type="text/css" /> |
|---|
| 7 | <title>Bounded Array;</title> |
|---|
| 8 | </head> |
|---|
| 9 | <body> |
|---|
| 10 | <h1><img src="../../../../boost.png" align="middle" /> |
|---|
| 11 | Bounded Array Storage</h1> |
|---|
| 12 | <h2><a name="bounded_array" id="bounded_array"></a>Bounded Array</h2> |
|---|
| 13 | <h4>Description</h4> |
|---|
| 14 | <p>The templated class <code>bounded_array<T, N, ALLOC></code> implements a bounded storage array. The bounded array is similar to a C++ array type in that its maximum size is bounded by N and is allocated on the stack instead of the heap. Similarly a <code>bounded_array</code> requires no secondary storage and ALLOC is only used to specify <code>size_type</code> and <code>difference_type</code>. |
|---|
| 15 | </p> |
|---|
| 16 | <p>When resized <code>bounded_array</code> never reallocated the storage. It is therefore always efficient to resize a <code>bounded_array</code> but the size bound N must not be exceeded.</p> |
|---|
| 17 | <h4>Example</h4> |
|---|
| 18 | <pre> |
|---|
| 19 | #include <boost/numeric/ublas/storage.hpp> |
|---|
| 20 | |
|---|
| 21 | int main () { |
|---|
| 22 | using namespace boost::numeric::ublas; |
|---|
| 23 | bounded_array<double, 3> a (3); |
|---|
| 24 | for (unsigned i = 0; i < a.size (); ++ i) { |
|---|
| 25 | a [i] = i; |
|---|
| 26 | std::cout << a [i] << std::endl; |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | </pre> |
|---|
| 30 | <h4>Definition</h4> |
|---|
| 31 | <p>Defined in the header storage.hpp.</p> |
|---|
| 32 | <h4>Template parameters</h4> |
|---|
| 33 | <table border="1" summary="parameters"> |
|---|
| 34 | <tbody> |
|---|
| 35 | <tr> |
|---|
| 36 | <th>Parameter</th> |
|---|
| 37 | <th>Description</th> |
|---|
| 38 | <th>Default</th> |
|---|
| 39 | </tr> |
|---|
| 40 | <tr> |
|---|
| 41 | <td><code>T</code></td> |
|---|
| 42 | <td>The type of object stored in the array.</td> |
|---|
| 43 | <td></td> |
|---|
| 44 | </tr> |
|---|
| 45 | <tr> |
|---|
| 46 | <td><code>N</code></td> |
|---|
| 47 | <td>The allocation size of 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.htm">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 |
|---|
| 66 | in the corresponding concept documentation, but instead contains a remark on the implementation of the |
|---|
| 67 | member 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> |
|---|
| 93 | <td><code>bounded_array ()</code></td> |
|---|
| 94 | <td><a href="storage_concept.htm">Storage</a></td> |
|---|
| 95 | <td>Creates an <code>unbounded_array</code> that holds <strong>zero</strong> elements.</td> |
|---|
| 96 | </tr> |
|---|
| 97 | <tr> |
|---|
| 98 | <td><code>bounded_array (size_type size)</code></td> |
|---|
| 99 | <td><a href="storage_concept.htm">Storage</a></td> |
|---|
| 100 | <td>Creates a uninitialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are default constructed.</td> |
|---|
| 101 | </tr> |
|---|
| 102 | <tr> |
|---|
| 103 | <td><code>bounded_array (size_type size, const T& init)</code></td> |
|---|
| 104 | <td><a href="storage_concept.htm">Storage</a></td> |
|---|
| 105 | <td>Creates an initialized <code>bounded_array</code> that holds <code>size</code> elements. All the elements are constructed from the <code>init</code> value.</td> |
|---|
| 106 | </tr> |
|---|
| 107 | <tr> |
|---|
| 108 | <td><code>bounded_array (const bounded_array &c)</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>~bounded_array ()</code></td> |
|---|
| 114 | <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> |
|---|
| 115 | <td>Deallocates the <code>bounded_array</code> itself.</td> |
|---|
| 116 | </tr> |
|---|
| 117 | <tr> |
|---|
| 118 | <td><code>void resize (size_type size)</code></td> |
|---|
| 119 | <td><a href="storage_concept.htm">Storage</a> |
|---|
| 120 | <td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td> |
|---|
| 121 | </tr> |
|---|
| 122 | <tr> |
|---|
| 123 | <td><code>void resize (size_type size, const T& t)</code></td> |
|---|
| 124 | <td><a href="storage_concept.htm">Storage</a> |
|---|
| 125 | <td>Reallocates a <code>bounded_array</code> to hold <code>size</code> elements.</td> |
|---|
| 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>bounded_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>bounded_array &operator = (const bounded_array &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>bounded_array &assign_temporary (bounded_array &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 (bounded_array &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 of the <code>bounded_array</code>.</td> |
|---|
| 161 | </tr> |
|---|
| 162 | <tr> |
|---|
| 163 | <td><code>const_iterator end () const</code></td> |
|---|
| 164 | <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> |
|---|
| 165 | <td>Returns a <code>const_iterator</code> pointing to the end of the <code>bounded_array</code>.</td> |
|---|
| 166 | </tr> |
|---|
| 167 | <tr> |
|---|
| 168 | <td><code>iterator begin ()</code></td> |
|---|
| 169 | <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> |
|---|
| 170 | <td>Returns a <code>iterator</code> pointing to the beginning of the <code>bounded_array</code>.</td> |
|---|
| 171 | </tr> |
|---|
| 172 | <tr> |
|---|
| 173 | <td><code>iterator end ()</code></td> |
|---|
| 174 | <td><a href="http://www.sgi.com/tech/stl/Container.html">Container</a></td> |
|---|
| 175 | <td>Returns a <code>iterator</code> pointing to the end of the <code>bounded_array</code>.</td> |
|---|
| 176 | </tr> |
|---|
| 177 | <tr> |
|---|
| 178 | <td><code>const_reverse_iterator rbegin () const</code></td> |
|---|
| 179 | <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> |
|---|
| 180 | <td>Returns a <code>const_reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td> |
|---|
| 181 | </tr> |
|---|
| 182 | <tr> |
|---|
| 183 | <td><code>const_reverse_iterator rend () 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 end of the reversed <code>bounded_array</code>.</td> |
|---|
| 186 | </tr> |
|---|
| 187 | <tr> |
|---|
| 188 | <td><code>reverse_iterator rbegin ()</code></td> |
|---|
| 189 | <td><a href="http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container</a></td> |
|---|
| 190 | <td>Returns a <code>reverse_iterator</code> pointing to the beginning of the reversed <code>bounded_array</code>.</td> |
|---|
| 191 | </tr> |
|---|
| 192 | <tr> |
|---|
| 193 | <td><code>reverse_iterator rend ()</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 end of the reversed <code>bounded_array</code>.</td> |
|---|
| 196 | </tr> |
|---|
| 197 | </tbody> |
|---|
| 198 | </table> |
|---|
| 199 | </body> |
|---|
| 200 | </html> |
|---|