mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-11 12:12:29 +00:00
346 lines
8.9 KiB
HTML
346 lines
8.9 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>Sparse Storage</title>
|
|
</head>
|
|
<body bgcolor="#ffffff">
|
|
<h1><img src="c++boost.gif" alt="c++boost.gif" align="Center">
|
|
Sparse Storage</h1>
|
|
|
|
<h2><a name="map_array"></a> Map Array</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>map_array<I, T></code>
|
|
implements a simple std::map-like associative container as a sorted
|
|
array.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/storage_sparse.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
map_array<int, 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>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header storage_sparse.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>I</code></td>
|
|
<td>The type of index stored in the array.</td>
|
|
<td> </td>
|
|
</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>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>map_array ()</code> </td>
|
|
<td>Allocates a <code>map_array</code> that holds at most zero
|
|
elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>map_array (size_type size)</code></td>
|
|
<td>Allocates a <code>map_array</code> that holds at most
|
|
<code>size</code> elements.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>map_array (const map_array &a)</code></td>
|
|
<td>The copy constructor.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>~map_array ()</code></td>
|
|
<td>Deallocates the <code>map_array</code> itself.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void resize (size_type size)</code></td>
|
|
<td>Reallocates a <code>map_array</code> to hold at most
|
|
<code>size</code> elements. The content of the
|
|
<code>map_array</code> is preserved.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the <code>map_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>data_reference operator [] (index_type i)</code></td>
|
|
<td>Returns a reference of the element that is associated with a
|
|
particular index. If the <code>map_array</code> does not already
|
|
contain such an element, <code>operator[]</code> inserts the
|
|
default <code>T ()</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>map_array &operator = (const map_array
|
|
&a)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>map_array &assign_temporary (map_array
|
|
&a)</code></td>
|
|
<td>Assigns a temporary. May change the array <code>a</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (map_array &a)</code></td>
|
|
<td>Swaps the contents of the arrays.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer insert (pointer it, const value_type
|
|
&p)</code></td>
|
|
<td>Inserts <code>p</code> into the array, using <code>it</code> as
|
|
a hint to where it will be inserted.</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_pointer find (index_type i) const</code></td>
|
|
<td>Finds an element whose index is <code>i</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer find (index_type i)</code></td>
|
|
<td>Finds an element whose index is <code>i</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_pointer lower_bound (index_type i)
|
|
const</code></td>
|
|
<td>Finds the first element whose index is not less than
|
|
<code>i</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer lower_bound (index_type i)</code></td>
|
|
<td>Finds the first element whose index is not less than
|
|
<code>i</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_pointer upper_bound (index_type i)
|
|
const</code></td>
|
|
<td>Finds the first element whose index is greater than
|
|
<code>i</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>pointer upper_bound (index_type i)</code></td>
|
|
<td>Finds the first element whose index is greater than
|
|
<code>i</code> .</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>map_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>map_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>map_array</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>map_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>map_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>map_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>map_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>map_array</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Map array<br>
|
|
template<class I, class T><br>
|
|
class map_array {<br>
|
|
public:<br>
|
|
typedef std::size_t size_type;<br>
|
|
typedef std::ptrdiff_t difference_type;<br>
|
|
typedef I index_type;<br>
|
|
typedef T data_value_type;<br>
|
|
typedef const T &data_const_reference;<br>
|
|
typedef T &data_reference;<br>
|
|
typedef std::pair<I, T> value_type;<br>
|
|
typedef const std::pair<I, T> &const_reference;<br>
|
|
typedef std::pair<I, T> &reference;<br>
|
|
typedef const std::pair<I, T> *const_pointer;<br>
|
|
typedef std::pair<I, T> *pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
map_array ();<br>
|
|
map_array (size_type size);<br>
|
|
map_array (const map_array &a);<br>
|
|
~map_array ();<br>
|
|
<br>
|
|
// Resizing<br>
|
|
void resize (size_type size);<br>
|
|
<br>
|
|
size_type size () const;<br>
|
|
<br>
|
|
// Element access<br>
|
|
data_reference operator [] (index_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
map_array &operator = (const map_array &a);<br>
|
|
map_array &assign_temporary (map_array &a);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (map_array &a);<br>
|
|
friend void swap (map_array &a1, map_array &a2);<br>
|
|
<br>
|
|
// Element insertion and deletion<br>
|
|
pointer insert (pointer it, const value_type &p);<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>
|
|
// Element lookup<br>
|
|
const_pointer find (index_type i) const;<br>
|
|
pointer find (index_type i);<br>
|
|
const_pointer lower_bound (index_type i) const;<br>
|
|
pointer lower_bound (index_type i);<br>
|
|
const_pointer upper_bound (index_type i) const;<br>
|
|
pointer upper_bound (index_type i);<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 I, class T><br>
|
|
map_array<I, T> &assign_temporary (map_array<I, T> &a1, map_array<I, T> &a2);</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>
|
|
|