File: range.htm

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (210 lines) | stat: -rw-r--r-- 6,665 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link href="ublas.css" type="text/css" />
<title>Range and slice</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />
Range and Slice Storage</h1>
<h2><a name="range" id="range"></a>Range&lt;SizeType,DistanceType&gt;</h2>
<h4>Description</h4>
<p>The class <code>range</code> specifies a range of indicies. The range is a sequence of indices
from a start value to stop value. The indices increase by one and exlude the stop value.
<code>range</code> can therefore be used to specify ranges of elements from vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    range r (0, 3);
    for (unsigned i = 0; i &lt; r.size (); ++ i) {
        std::cout &lt;&lt; r (i) &lt;&lt; std::endl;
    }
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>range (size_type start, size_type stop)</code></td>
<td>Constructs a range of indicies from <code>start</code> to <code>stop (excluded)</code>
.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>range</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i</code> of the <code>i</code>
-th element.</td>
</tr>
<tr>
<td><code>range compose (const range &amp;r) const</code></td>
<td>Returns the composite range from <code>start + r.start
()</code> to <code>start + r.start () + r.size ()</code>.</td>
</tr>
<tr>
<td><code>bool operator == (const range &amp;r) const</code></td>
<td>Tests two ranges for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const range &amp;r) const</code></td>
<td>Tests two ranges for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>range</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li><code>start () &lt;= stop ()</code></li>
</ul>

<h2><a name="slice" id="slice"></a>Slice&lt;SizeType,DistanceType&gt;</h2>
<h4>Description</h4>
<p>The class <code>slice</code> specifies a 'slice' of indicies. Slices are more general
then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element.
<code>slice</code> can therefore be used to specify slices of element from vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    slice s (0, 1, 3);
    for (unsigned i = 0; i &lt; s.size (); ++ i) {
        std::cout &lt;&lt; s (i) &lt;&lt; std::endl;
    }
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>slice (size_type start, size_type stride, size_type
size)</code></td>
<td>Constructs a slice <code>start,start+stride,start+2*stride...</code> with 
<code>size</code> elements.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type stride () const</code></td>
<td>Returns the stride of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i * stride</code> of the
<code>i</code>-th element.</td>
</tr>
<tr>
<td><code>slice compose (const range &amp;r) const</code></td>
<td>Returns the composite slice from <code>start + stride * r.start
()</code> to <code>start + stride * (r.start () + r.size ())</code>
with stride <code>stride</code>.</td>
</tr>
<tr>
<td><code>slice compose (const slice &amp;s) const</code></td>
<td>Returns the composite slice from <code>start + stride * s.start
()</code> to <code>start + stride * s.stride () * (s.start () +
s.size ())</code> with stride <code>stride * s.stride ()</code>
.</td>
</tr>
<tr>
<td><code>bool operator == (const slice &amp;s) const</code></td>
<td>Tests two slices for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const slice &amp;s) const</code></td>
<td>Tests two slices for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>slice</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li>None all strides are vaild. However when an index is returned or an iterator is dereferenced its
value must be representable as the size_type.</li>
</ul>
</body>
</html>