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 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>Bounded Array;
</title>
13 <h1><img src=
"../../../../boost.png" align=
"middle" />Bounded Array Storage
</h1>
14 <div class=
"toc" id=
"toc"></div>
15 <h2><a name=
"bounded_array"></a>Bounded Array
</h2>
17 <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>.
19 <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>
22 #include
<boost/numeric/ublas/storage.hpp
>
25 using namespace boost::numeric::ublas;
26 bounded_array
<double,
3> a (
3);
27 for (unsigned i =
0; i
< a.size (); ++ i) {
29 std::cout
<< a [i]
<< std::endl;
34 <p>Defined in the header storage.hpp.
</p>
35 <h4>Template parameters
</h4>
36 <table border=
"1" summary=
"parameters">
44 <td><code>T
</code></td>
45 <td>The type of object stored in the array.
</td>
49 <td><code>N
</code></td>
50 <td>The allocation size of the array.
</td>
54 <td><code>ALLOC
</code></td>
55 <td>An STL Allocator
</td>
56 <td>std::allocator
</td>
61 <p><a href=
"storage_concept.html">Storage
</a></p>
62 <h4>Type requirements
</h4>
63 <p>None, except for those imposed by the requirements of Storage.
</p>
64 <h4>Public base classes
</h4>
68 <li>The description does not describe what the member actually does, this can be looked up
69 in the corresponding concept documentation, but instead contains a remark on the implementation of the
70 member inside this model of the concept.
</li>
73 <li>Members that are not part of the implemented concepts are
<font color=
"blue">in blue
</font>.
</li>
77 <table border=
"1" summary=
"members">
81 <th>Where defined
</th>
84 <tr><td><code>value_type
</code></td><td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td><td></tr>
85 <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>
86 <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>
87 <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>
88 <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>
89 <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>
90 <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>
91 <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>
92 <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>
93 <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>
94 <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>
96 <td><code>bounded_array ()
</code></td>
97 <td><a href=
"storage_concept.html">Storage
</a></td>
98 <td>Creates an
<code>unbounded_array
</code> that holds
<strong>zero
</strong> elements.
</td>
101 <td><code>bounded_array (size_type size)
</code></td>
102 <td><a href=
"storage_concept.html">Storage
</a></td>
103 <td>Creates a uninitialized
<code>bounded_array
</code> that holds
<code>size
</code> elements. All the elements are default constructed.
</td>
106 <td><code>bounded_array (size_type size, const T
& init)
</code></td>
107 <td><a href=
"storage_concept.html">Storage
</a></td>
108 <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>
111 <td><code>bounded_array (const bounded_array
&c)
</code></td>
112 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
113 <td>The copy constructor.
</td>
116 <td><code>~bounded_array ()
</code></td>
117 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
118 <td>Deallocates the
<code>bounded_array
</code> itself.
</td>
121 <td><code>void resize (size_type size)
</code></td>
122 <td><a href=
"storage_concept.html">Storage
</a>
123 <td>Reallocates a
<code>bounded_array
</code> to hold
<code>size
</code> elements.
</td>
126 <td><code>void resize (size_type size, const T
& t)
</code></td>
127 <td><a href=
"storage_concept.html">Storage
</a>
128 <td>Reallocates a
<code>bounded_array
</code> to hold
<code>size
</code> elements.
</td>
131 <td><code>size_type size () const
</code></td>
132 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
133 <td>Returns the size of the
<code>bounded_array
</code>.
</td>
136 <td><code>const_reference operator [] (size_type i) const
</code></td>
137 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
138 <td>Returns a
<code>const
</code> reference of the
<code>i
</code> -th element.
</td>
141 <td><code>reference operator [] (size_type i)
</code></td>
142 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
143 <td>Returns a reference of the
<code>i
</code>-th element.
</td>
146 <td><code>bounded_array
&operator = (const bounded_array
&a)
</code></td>
147 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
148 <td>The assignment operator.
</td>
151 <td><font color=
"blue"><code>bounded_array
&assign_temporary (bounded_array
&a)
</code></font></td>
153 <td>Assigns a temporary. May change the array
<code>a
</code>.
</td>
156 <td><code>void swap (bounded_array
&a)
</code></td>
157 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
158 <td>Swaps the contents of the arrays.
</td>
161 <td><code>const_iterator begin () const
</code></td>
162 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
163 <td>Returns a
<code>const_iterator
</code> pointing to the beginning of the
<code>bounded_array
</code>.
</td>
166 <td><code>const_iterator end () const
</code></td>
167 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
168 <td>Returns a
<code>const_iterator
</code> pointing to the end of the
<code>bounded_array
</code>.
</td>
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 the
<code>bounded_array
</code>.
</td>
176 <td><code>iterator end ()
</code></td>
177 <td><a href=
"http://www.sgi.com/tech/stl/Container.html">Container
</a></td>
178 <td>Returns a
<code>iterator
</code> pointing to the end of the
<code>bounded_array
</code>.
</td>
181 <td><code>const_reverse_iterator rbegin () const
</code></td>
182 <td><a href=
"http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container
</a></td>
183 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the beginning of the reversed
<code>bounded_array
</code>.
</td>
186 <td><code>const_reverse_iterator rend () const
</code></td>
187 <td><a href=
"http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container
</a></td>
188 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the end of the reversed
<code>bounded_array
</code>.
</td>
191 <td><code>reverse_iterator rbegin ()
</code></td>
192 <td><a href=
"http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container
</a></td>
193 <td>Returns a
<code>reverse_iterator
</code> pointing to the beginning of the reversed
<code>bounded_array
</code>.
</td>
196 <td><code>reverse_iterator rend ()
</code></td>
197 <td><a href=
"http://www.sgi.com/tech/stl/ReversibleContainer.html">Reversible Container
</a></td>
198 <td>Returns a
<code>reverse_iterator
</code> pointing to the end of the reversed
<code>bounded_array
</code>.
</td>
204 Copyright (
©)
2000-
2004 Michael Stevens, Mathias Koch,
205 Joerg Walter, Gunter Winkler
<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
213 <script type=
"text/javascript">