...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The templated class unbounded_array<T>
implements a simple C-like array using allocation via
new/delete
.
#include <boost/numeric/ublas/storage.hpp>
int main () {
using namespace boost::numeric::ublas;
unbounded_array<double> a (3);
for (unsigned i = 0; i < a.size (); ++ i) {
a [i] = i;
std::cout << a [i] << std::endl;
}
}
Defined in the header storage.hpp.
Parameter | Description | Default |
---|---|---|
T |
The type of object stored in the array. |
Random Access Container.
None, except for those imposed by the requirements of Random Access Container.
None.
Member | Description |
---|---|
unbounded_array () |
Allocates an uninitialized unbounded_array that
holds at most zero elements. |
unbounded_array (size_type size) |
Allocates an uninitialized unbounded_array that
holds at most size elements. |
unbounded_array (const unbounded_array
&a) |
The copy constructor. |
~unbounded_array () |
Deallocates the unbounded_array itself. |
void resize (size_type size) |
Reallocates an unbounded_array to hold at most
size elements. The content of the
unbounded_array is not preserved. |
size_type size () const |
Returns the size of the unbounded_array . |
const_reference operator [] (size_type i)
const |
Returns a const reference of the i
-th element. |
reference operator [] (size_type i) |
Returns a reference of the i -th element. |
unbounded_array &operator = (const unbounded_array
&a) |
The assignment operator. |
unbounded_array &assign_temporary (unbounded_array
&a) |
Assigns a temporary. May change the array a . |
void swap (unbounded_array &a) |
Swaps the contents of the arrays. |
pointer insert (pointer it, const value_type
&t) |
Inserts the value t at it . |
void erase (pointer it) |
Erases the value at it . |
void clear () |
Clears the array. |
const_iterator begin () const |
Returns a const_iterator pointing to the beginning
of the unbounded_array . |
const_iterator end () const |
Returns a const_iterator pointing to the end of
the unbounded_array . |
iterator begin () |
Returns a iterator pointing to the beginning of
the unbounded_array . |
iterator end () |
Returns a iterator pointing to the end of the
unbounded_array . |
const_reverse_iterator rbegin () const |
Returns a const_reverse_iterator pointing to the
beginning of the reversed unbounded_array . |
const_reverse_iterator rend () const |
Returns a const_reverse_iterator pointing to the
end of the reversed unbounded_array . |
reverse_iterator rbegin () |
Returns a reverse_iterator pointing to the
beginning of the reversed unbounded_array . |
reverse_iterator rend () |
Returns a reverse_iterator pointing to the end of
the reversed unbounded_array . |
The templated class bounded_array<T, N>
implements a simple C-like array.
#include <boost/numeric/ublas/storage.hpp>
int main () {
using namespace boost::numeric::ublas;
bounded_array<double, 3> a (3);
for (unsigned i = 0; i < a.size (); ++ i) {
a [i] = i;
std::cout << a [i] << std::endl;
}
}
Defined in the header storage.hpp.
Parameter | Description | Default |
---|---|---|
T |
The type of object stored in the array. | |
N |
The allocation size of the array. |
Random Access Container.
None, except for those imposed by the requirements of Random Access Container.
None.
Member | Description |
---|---|
bounded_array () |
Allocates an uninitialized bounded_array that
holds at most zero elements. |
bounded_array (size_type size) |
Allocates an uninitialized bounded_array that
holds at most size elements. |
bounded_array (const bounded_array &a) |
The copy constructor. |
~bounded_array () |
Deallocates the bounded_array itself. |
void resize (size_type size) |
Reallocates a bounded_array to hold at most
size elements. The content of the
bounded_array is preserved. |
size_type size () const |
Returns the size of the bounded_array . |
const_reference operator [] (size_type i)
const |
Returns a const reference of the i
-th element. |
reference operator [] (size_type i) |
Returns a reference of the i -th element. |
bounded_array &operator = (const bounded_array
&a) |
The assignment operator. |
bounded_array &assign_temporary (bounded_array
&a) |
Assigns a temporary. May change the array a . |
void swap (bounded_array &a) |
Swaps the contents of the arrays. |
pointer insert (pointer it, const value_type
&t) |
Inserts the value t at it . |
void erase (pointer it) |
Erases the value at it . |
void clear () |
Clears the array. |
const_iterator begin () const |
Returns a const_iterator pointing to the beginning
of the bounded_array . |
const_iterator end () const |
Returns a const_iterator pointing to the end of
the bounded_array . |
iterator begin () |
Returns a iterator pointing to the beginning of
the bounded_array . |
iterator end () |
Returns a iterator pointing to the end of the
bounded_array . |
const_reverse_iterator rbegin () const |
Returns a const_reverse_iterator pointing to the
beginning of the reversed bounded_array . |
const_reverse_iterator rend () const |
Returns a const_reverse_iterator pointing to the
end of the reversed bounded_array . |
reverse_iterator rbegin () |
Returns a reverse_iterator pointing to the
beginning of the reversed bounded_array . |
reverse_iterator rend () |
Returns a reverse_iterator pointing to the end of
the reversed bounded_array . |
The class range
implements base functionality
needed to address ranges of vectors and matrices.
#include <boost/numeric/ublas/storage.hpp>
int main () {
using namespace boost::numeric::ublas;
range r (0, 3);
for (unsigned i = 0; i < r.size (); ++ i) {
std::cout << r (i) << std::endl;
}
}
Defined in the header storage.hpp.
Reversible Container.
None, except for those imposed by the requirements of Reversible Container.
None.
Member | Description |
---|---|
range (size_type start, size_type stop) |
Constructs a range from start to stop
. |
size_type start () const |
Returns the beginning of the range . |
size_type size () const |
Returns the size of the range . |
const_reference operator [] (size_type i)
const |
Returns the value start + i of the i
-th element. |
range compose (const range &r) const |
Returns the composite range from start + r.start
() to start + r.start () + r.size () . |
bool operator == (const range &r) const |
Tests two ranges for equality. |
bool operator != (const range &r) const |
Tests two ranges for inequality. |
const_iterator begin () const |
Returns a const_iterator pointing to the beginning
of the range . |
const_iterator end () const |
Returns a const_iterator pointing to the end of
the range . |
const_reverse_iterator rbegin () const |
Returns a const_reverse_iterator pointing to the
beginning of the reversed range . |
const_reverse_iterator rend () const |
Returns a const_reverse_iterator pointing to the
end of the reversed range . |
The class slice
implements base functionality
needed to address slices of vectors and matrices.
#include <boost/numeric/ublas/storage.hpp>
int main () {
using namespace boost::numeric::ublas;
slice s (0, 1, 3);
for (unsigned i = 0; i < s.size (); ++ i) {
std::cout << s (i) << std::endl;
}
}
Defined in the header storage.hpp.
Reversible Container.
None, except for those imposed by the requirements of Reversible Container.
None.
Member | Description |
---|---|
slice (size_type start, size_type stride, size_type
size) |
Constructs a slice from start to start +
size with stride stride . |
size_type start () const |
Returns the beginning of the slice . |
size_type stride () const |
Returns the stride of the slice . |
size_type size () const |
Returns the size of the slice . |
const_reference operator [] (size_type i)
const |
Returns the value start + i * stride of the
i -th element. |
slice compose (const range &r) const |
Returns the composite slice from start + stride * r.start
() to start + stride * (r.start () + r.size ())
with stride stride . |
slice compose (const slice &s) const |
Returns the composite slice from start + stride * s.start
() to start + stride * s.stride () * (s.start () +
s.size ()) with stride stride * s.stride ()
. |
bool operator == (const slice &s) const |
Tests two slices for equality. |
bool operator != (const slice &s) const |
Tests two slices for inequality. |
const_iterator begin () const |
Returns a const_iterator pointing to the beginning
of the slice . |
const_iterator end () const |
Returns a const_iterator pointing to the end of
the slice . |
const_reverse_iterator rbegin () const |
Returns a const_reverse_iterator pointing to the
beginning of the reversed slice . |
const_reverse_iterator rend () const |
Returns a const_reverse_iterator pointing to the
end of the reversed slice . |
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
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.
Last revised: 1/15/2003