mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-13 00:42:14 +00:00
962 lines
25 KiB
HTML
962 lines
25 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=iso-8859-1">
|
|
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
|
<title>Storage</title>
|
|
</head>
|
|
<body bgcolor="#ffffff">
|
|
<h1><img src="c++boost.gif" alt="c++boost.gif" align="Center">
|
|
Storage</h1>
|
|
|
|
<h2><a name="unbounded_array"></a> Unbounded Array</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>unbounded_array<T></code>
|
|
implements a simple C-like array using allocation via
|
|
<code>new/delete</code>.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/storage.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
unbounded_array<double> a (3);<br>
|
|
for (unsigned i = 0; i < a.size (); ++ i) {<br>
|
|
a [i] = i;<br>
|
|
std::cout << a [i] << std::endl;<br>
|
|
}<br>
|
|
}
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header storage.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>T</code></td>
|
|
<td>The type of object stored in the array.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p>Random Access Container.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of Random
|
|
Access Container.</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>unbounded_array ()</code></td>
|
|
<td>Allocates an uninitialized <code>unbounded_array</code> that
|
|
holds at most zero elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>unbounded_array (size_type size)</code></td>
|
|
<td>Allocates an uninitialized <code>unbounded_array</code> that
|
|
holds at most <code>size</code> elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>unbounded_array (const unbounded_array
|
|
&a)</code></td>
|
|
<td>The copy constructor.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>~unbounded_array ()</code></td>
|
|
<td>Deallocates the <code>unbounded_array</code> itself.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void resize (size_type size)</code></td>
|
|
<td>Reallocates an <code>unbounded_array</code> to hold at most
|
|
<code>size</code> elements. The content of the
|
|
<code>unbounded_array</code> is not preserved.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the <code>unbounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator [] (size_type i)
|
|
const</code></td>
|
|
<td>Returns a <code>const</code> reference of the <code>i</code>
|
|
-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator [] (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>unbounded_array &operator = (const unbounded_array
|
|
&a)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>unbounded_array &assign_temporary (unbounded_array
|
|
&a)</code></td>
|
|
<td>Assigns a temporary. May change the array <code>a</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (unbounded_array &a)</code></td>
|
|
<td>Swaps the contents of the arrays.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer insert (pointer it, const value_type
|
|
&t)</code></td>
|
|
<td>Inserts the value <code>t</code> at <code>it</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void erase (pointer it)</code></td>
|
|
<td>Erases the value at <code>it</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void clear ()</code></td>
|
|
<td>Clears the array.</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>unbounded_array</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>unbounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>unbounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>unbounded_array</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>unbounded_array</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>unbounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>unbounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>unbounded_array</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Unbounded array<br>
|
|
template<class T><br>
|
|
class unbounded_array {<br>
|
|
public:<br>
|
|
typedef std::size_t size_type;<br>
|
|
typedef std::ptrdiff_t difference_type;<br>
|
|
typedef T value_type;<br>
|
|
typedef const T &const_reference;<br>
|
|
typedef T &reference;<br>
|
|
typedef const T *const_pointer;<br>
|
|
typedef T *pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
unbounded_array ();<br>
|
|
unbounded_array (size_type size);<br>
|
|
unbounded_array (const unbounded_array &a);<br>
|
|
~unbounded_array ();<br>
|
|
<br>
|
|
// Resizing<br>
|
|
void resize (size_type size);<br>
|
|
<br>
|
|
size_type size () const;<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator [] (size_type i) const;<br>
|
|
reference operator [] (size_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
unbounded_array &operator = (const unbounded_array &a);<br>
|
|
unbounded_array &assign_temporary (unbounded_array &a);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (unbounded_array &a);<br>
|
|
friend void swap (unbounded_array &a1, unbounded_array &a2);<br>
|
|
<br>
|
|
// Element insertion and deletion<br>
|
|
pointer insert (pointer it, const value_type &t);<br>
|
|
void insert (pointer it, pointer it1, pointer it2);<br>
|
|
void erase (pointer it);<br>
|
|
void erase (pointer it1, pointer it2);<br>
|
|
void clear ();<br>
|
|
<br>
|
|
// Iterators simply are pointers.<br>
|
|
<br>
|
|
typedef const_pointer const_iterator;<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
typedef pointer iterator;<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterators<br>
|
|
<br>
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef std::reverse_iterator<iterator> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};<br>
|
|
<br>
|
|
template<class T><br>
|
|
unbounded_array<T> &assign_temporary (unbounded_array<T> &a1, unbounded_array<T> &a2);</code>
|
|
</pre>
|
|
|
|
<h2><a name="bounded_array"></a> Bounded Array</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>bounded_array<T, N></code>
|
|
implements a simple C-like array.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/storage.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
bounded_array<double, 3> a (3);<br>
|
|
for (unsigned i = 0; i < a.size (); ++ i) {<br>
|
|
a [i] = i;<br>
|
|
std::cout << a [i] << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header storage.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>T</code></td>
|
|
<td>The type of object stored in the array.</td>
|
|
<td> </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>N</code></td>
|
|
<td>The allocation size of the array.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p>Random Access Container.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of Random
|
|
Access Container.</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bounded_array ()</code></td>
|
|
<td>Allocates an uninitialized <code>bounded_array</code> that
|
|
holds at most zero elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bounded_array (size_type size)</code></td>
|
|
<td>Allocates an uninitialized <code>bounded_array</code> that
|
|
holds at most <code>size</code> elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bounded_array (const bounded_array &a)</code></td>
|
|
<td>The copy constructor.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>~bounded_array ()</code></td>
|
|
<td>Deallocates the <code>bounded_array</code> itself.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void resize (size_type size)</code></td>
|
|
<td>Reallocates a <code>bounded_array</code> to hold at most
|
|
<code>size</code> elements. The content of the
|
|
<code>bounded_array</code> is preserved.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the <code>bounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator [] (size_type i)
|
|
const</code></td>
|
|
<td>Returns a <code>const</code> reference of the <code>i</code>
|
|
-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator [] (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bounded_array &operator = (const bounded_array
|
|
&a)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bounded_array &assign_temporary (bounded_array
|
|
&a)</code></td>
|
|
<td>Assigns a temporary. May change the array <code>a</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (bounded_array &a)</code></td>
|
|
<td>Swaps the contents of the arrays.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer insert (pointer it, const value_type
|
|
&t)</code></td>
|
|
<td>Inserts the value <code>t</code> at <code>it</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void erase (pointer it)</code></td>
|
|
<td>Erases the value at <code>it</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void clear ()</code></td>
|
|
<td>Clears the array.</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>bounded_array</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>bounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>bounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>bounded_array</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>bounded_array</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>bounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>bounded_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>bounded_array</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Bounded array<br>
|
|
template<class T, std::size_t N><br>
|
|
class bounded_array {<br>
|
|
public:<br>
|
|
typedef std::size_t size_type;<br>
|
|
typedef std::ptrdiff_t difference_type;<br>
|
|
typedef T value_type;<br>
|
|
typedef const T &const_reference;<br>
|
|
typedef T &reference;<br>
|
|
typedef const T *const_pointer;<br>
|
|
typedef T *pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
bounded_array ();<br>
|
|
bounded_array (size_type size);<br>
|
|
bounded_array (const bounded_array &a);<br>
|
|
<br>
|
|
// Resizing<br>
|
|
void resize (size_type size);<br>
|
|
<br>
|
|
size_type size () const;<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator [] (size_type i) const;<br>
|
|
reference operator [] (size_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
bounded_array &operator = (const bounded_array &a);<br>
|
|
bounded_array &assign_temporary (bounded_array &a);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (bounded_array &a);<br>
|
|
friend void swap (bounded_array &a1, bounded_array &a2);<br>
|
|
<br>
|
|
// Element insertion and deletion<br>
|
|
pointer insert (pointer it, const value_type &t);<br>
|
|
void insert (pointer it, pointer it1, pointer it2);<br>
|
|
void erase (pointer it);<br>
|
|
void erase (pointer it1, pointer it2);<br>
|
|
void clear ();<br>
|
|
<br>
|
|
// Iterators simply are pointers.<br>
|
|
<br>
|
|
typedef const_pointer const_iterator;<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
typedef pointer iterator;<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterators<br>
|
|
<br>
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef std::reverse_iterator<iterator, value_type, reference> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};<br>
|
|
<br>
|
|
template<class T, std::size_t N><br>
|
|
bounded_array<T, N> &assign_temporary (bounded_array<T, N> &a1, bounded_array<T, N> &a2);</code>
|
|
</pre>
|
|
|
|
<h2><a name="range"></a> Range</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The class <code>range</code> implements base functionality
|
|
needed to address ranges of vectors and matrices.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/storage.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
range r (0, 3);<br>
|
|
for (unsigned i = 0; i < r.size (); ++ i) {<br>
|
|
std::cout << r (i) << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</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">
|
|
<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 from <code>start</code> to <code>stop</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 &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 &r) const</code></td>
|
|
<td>Tests two ranges for equality.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bool operator != (const range &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>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Range class<br>
|
|
class range {<br>
|
|
public:<br>
|
|
typedef std::size_t size_type;<br>
|
|
typedef std::ptrdiff_t difference_type;<br>
|
|
typedef difference_type value_type;<br>
|
|
typedef value_type const_reference;<br>
|
|
typedef const_reference reference;<br>
|
|
typedef const difference_type *const_pointer;<br>
|
|
typedef difference_type *pointer;<br>
|
|
typedef size_type const_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
range ();<br>
|
|
range (size_type start, size_type stop);<br>
|
|
<br>
|
|
size_type start () const;<br>
|
|
size_type size () const;<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i) const;<br>
|
|
<br>
|
|
// Composition<br>
|
|
range compose (const range &r) const;<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const range &r) const;<br>
|
|
bool operator != (const range &r) const;<br>
|
|
<br>
|
|
// Iterator simply is a index.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<range>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const range &r, const const_iterator_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
const_reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h2><a name="slice"></a> Slice</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The class <code>slice</code> implements base functionality
|
|
needed to address slices of vectors and matrices.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/storage.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
slice s (0, 1, 3);<br>
|
|
for (unsigned i = 0; i < s.size (); ++ i) {<br>
|
|
std::cout << s (i) << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</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">
|
|
<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 from <code>start</code> to <code>start +
|
|
size</code> with stride <code>stride</code>.</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 &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 &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 &s) const</code></td>
|
|
<td>Tests two slices for equality.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>bool operator != (const slice &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>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Slice class<br>
|
|
class slice {<br>
|
|
public:<br>
|
|
typedef std::size_t size_type;<br>
|
|
typedef std::ptrdiff_t difference_type;<br>
|
|
typedef difference_type value_type;<br>
|
|
typedef value_type const_reference;<br>
|
|
typedef const_reference reference;<br>
|
|
typedef const difference_type *const_pointer;<br>
|
|
typedef difference_type *pointer;<br>
|
|
typedef size_type const_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
slice ();<br>
|
|
slice (size_type start, size_type stride, size_type size);<br>
|
|
<br>
|
|
size_type start () const;<br>
|
|
size_type stride () const;<br>
|
|
size_type size () const;<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i) const;<br>
|
|
<br>
|
|
// Composition<br>
|
|
slice compose (const range &r) const;<br>
|
|
slice compose (const slice &s) const;<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const slice &s) const;<br>
|
|
bool operator != (const slice &s) const;<br>
|
|
<br>
|
|
// Iterator simply is a index.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<slice>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const slice &s, const const_iterator_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
const_reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<hr>
|
|
<p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br>
|
|
Permission to copy, use, modify, sell and distribute this document
|
|
is granted provided this copyright notice appears in all copies.
|
|
This document is provided ``as is'' without express or implied
|
|
warranty, and with no claim as to its suitability for any
|
|
purpose.</p>
|
|
|
|
<p>Last revised: 1/15/2003</p>
|
|
</body>
|
|
</html>
|
|
|